allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [08/12] allura git commit: [#5940] ticket:866 fixed and updated tests of global_nav and logo
Date Mon, 07 Dec 2015 08:23:04 GMT
[#5940] ticket:866 fixed and updated tests of global_nav and logo


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

Branch: refs/heads/ib/5940
Commit: c113dbad71969d61426e786ac4dd164d23e95132
Parents: a725321
Author: DeV1doR <dev1dor@ukr.net>
Authored: Fri Dec 4 12:25:44 2015 +0200
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon Dec 7 10:01:07 2015 +0200

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py           |  2 +-
 Allura/allura/tests/functional/test_nav.py | 47 +++++++++++++++----------
 2 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c113dbad/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index c7aee45..6c0cf78 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -621,7 +621,7 @@ class Globals(object):
             return False
 
         if not logo.get('redirect_link', False):
-            logo['redirect_url'] = '/'
+            logo['redirect_link'] = '/'
         path = 'images/%s' % logo['image_path']
         return {
             "image_path": self.forge_static(path),

http://git-wip-us.apache.org/repos/asf/allura/blob/c113dbad/Allura/allura/tests/functional/test_nav.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_nav.py b/Allura/allura/tests/functional/test_nav.py
index 8f75bd8..c382941 100644
--- a/Allura/allura/tests/functional/test_nav.py
+++ b/Allura/allura/tests/functional/test_nav.py
@@ -9,7 +9,7 @@ from allura.lib import helpers as h
 
 class TestNavigation(TestController):
     """
-    Test left navigation in top nav.
+    Test div-logo and nav-left:
     - Test of global_nav links.
     - Test of logo.
     """
@@ -23,6 +23,10 @@ class TestNavigation(TestController):
         self.logo_data = {
             "redirect_link": "/", "image_path": "test_image.png"}
 
+    def tearDown(self):
+        g._Globals__shared_state.pop('global_nav', None)
+        g._Globals__shared_state.pop('nav_logo', None)
+
     def _set_config(self):
         return {
             "global_nav": json.dumps([self.nav_data]),
@@ -37,26 +41,33 @@ class TestNavigation(TestController):
         assert nav_left.a.get('href') == self.nav_data['url']
         assert nav_left.a.text == self.nav_data['title']
 
+    @mock.patch.object(g, 'global_nav', return_value=[])
+    def test_global_nav_links_absent(self, global_nav):
+        with h.push_config(config, **self._set_config()):
+            response = self.app.get('/')
+        nav_left = response.html.find(*self.global_nav_pattent)
+        assert len(nav_left.findAll('a')) == 0
+
     def test_logo_absent_if_not_image_path(self):
         with h.push_config(config, **self._set_config()):
             response = self.app.get('/')
         nav_logo = response.html.find(*self.logo_pattern)
         assert len(nav_logo.findAll('a')) == 0
 
-    # def test_logo_present(self):
-    #     self.logo_data = {
-    #         "redirect_link": "/", "image_path": "user.png"}
-    #     with h.push_config(config, **self._set_config()):
-    #         response = self.app.get('/')
-    #     nav_logo = response.html.find(*self.logo_pattern)
-    #     import ipdb; ipdb.set_trace()
-    #     assert len(nav_logo.findAll('a')) == 1
-
-    # def test_logo_no_redirect_url_set_default(self):
-    #     self.logo_data = {
-    #         "redirect_link": "", "image_path": "user.png"}
-    #     with h.push_config(config, **self._set_config()):
-    #         response = self.app.get('/')
-    #     nav_logo = response.html.find(*self.logo_pattern)
-    #     assert len(nav_logo.findAll('a')) == 1
-    #     assert nav_left.a.get('href') == '/'
+    def test_logo_present(self):
+        self.logo_data = {
+            "redirect_link": "/", "image_path": "user.png"}
+        with h.push_config(config, **self._set_config()):
+            response = self.app.get('/')
+        nav_logo = response.html.find(*self.logo_pattern)
+        assert len(nav_logo.findAll('a')) == 1
+        assert self.logo_data['image_path'] in nav_logo.a.img.get('src')
+
+    def test_logo_no_redirect_url_set_default(self):
+        self.logo_data = {
+            "redirect_link": "", "image_path": "user.png"}
+        with h.push_config(config, **self._set_config()):
+            response = self.app.get('/')
+        nav_logo = response.html.find(*self.logo_pattern)
+        assert len(nav_logo.findAll('a')) == 1
+        assert nav_logo.a.get('href') == '/'


Mime
View raw message