incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/3] git commit: [#7214] make admin landing page not error when tool not present
Date Tue, 25 Feb 2014 04:18:29 GMT
[#7214] make admin landing page not error when tool not present


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/17b1bea9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/17b1bea9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/17b1bea9

Branch: refs/heads/db/7214
Commit: 17b1bea9345e3b514ec615295a3c1710e739f271
Parents: 3827087
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon Feb 24 23:17:44 2014 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Feb 24 23:18:09 2014 -0500

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py        |  4 +++-
 Allura/allura/tests/test_plugin.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/17b1bea9/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 084501f..7773bf0 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -909,8 +909,10 @@ class ThemeProvider(object):
         if isinstance(app, str):
             if app in self.icons and size in self.icons[app]:
                 return g.theme_href(self.icons[app][size])
-            else:
+            elif app in g.entry_points['tool']:
                 return g.entry_points['tool'][app].icon_url(size)
+            else:
+                return None
         else:
             return app.icon_url(size)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/17b1bea9/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index 24a163a..d6f76d5 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -20,6 +20,7 @@ from mock import Mock, MagicMock, patch
 from datetime import timedelta
 
 from allura import model as M
+from allura.app import Application
 from allura.lib.utils import TruthyCallable
 from allura.lib.plugin import ProjectRegistrationProvider
 from allura.lib.plugin import ThemeProvider
@@ -153,3 +154,33 @@ class TestThemeProvider(object):
         assert_is(ThemeProvider().get_site_notification(), note)
         response.set_cookie.assert_called_once_with(
             'site-notification', 'deadbeef-1-False', max_age=timedelta(days=365))
+
+    @patch('allura.app.g')
+    @patch('allura.lib.plugin.g')
+    def test_app_icon_str(self, plugin_g, app_g):
+        class TestApp(Application):
+            icons = {
+                24: 'images/testapp_24.png',
+            }
+        plugin_g.entry_points = {'tool': {'testapp': TestApp}}
+        assert_equals(ThemeProvider().app_icon_url('testapp', 24),
+                      app_g.theme_href.return_value)
+        app_g.theme_href.assert_called_with('images/testapp_24.png')
+
+    @patch('allura.lib.plugin.g')
+    def test_app_icon_str_invalid(self, g):
+        g.entry_points = {'tool': {'testapp': Mock()}}
+        assert_equals(ThemeProvider().app_icon_url('invalid', 24),
+                      None)
+
+    @patch('allura.app.g')
+    def test_app_icon_app(self, g):
+        class TestApp(Application):
+            icons = {
+                24: 'images/testapp_24.png',
+            }
+        app = TestApp(None, None)
+        assert_equals(ThemeProvider().app_icon_url(app, 24),
+                      g.theme_href.return_value)
+        g.theme_href.assert_called_with('images/testapp_24.png')
+


Mime
View raw message