incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [5/5] git commit: [#4943] test for top nav, include newly installed tools on first pageload
Date Thu, 31 Jan 2013 20:26:42 GMT
Updated Branches:
  refs/heads/master c1e81ff02 -> be42517ff


[#4943] test for top nav, include newly installed tools on first pageload


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

Branch: refs/heads/master
Commit: be42517ffaf71cc20b3d963f0c47e73dd9df6145
Parents: ebbfce4
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Thu Jan 31 16:34:53 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Thu Jan 31 20:26:31 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py                     |    8 +++++---
 .../allura/tests/functional/test_neighborhood.py   |    5 +++++
 Allura/allura/tests/model/test_project.py          |    4 ++--
 3 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/be42517f/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index f12673f..df6fdc9 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -393,7 +393,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
 
         anchored_tools =self.neighborhood.get_anchored_tools()
         i = len(anchored_tools)
-        self.install_anchored_tools()
+        new_tools = self.install_anchored_tools()
 
         # Set menu mode
         delta_ordinal = i
@@ -409,7 +409,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             if ordinal > max_ordinal:
                 max_ordinal = ordinal
             entries.append({'ordinal':sub.ordinal + delta_ordinal,'entry':SitemapEntry(sub.name,
sub.url())})
-        for ac in self.app_configs:
+        for ac in self.app_configs + [a.config for a in new_tools]:
             if excluded_tools and ac.tool_name in excluded_tools:
                 continue
             # Tool could've been uninstalled in the meantime
@@ -444,14 +444,16 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         anchored_tools = self.neighborhood.get_anchored_tools()
         installed_tools = [tool.tool_name.lower() for tool in self.app_configs]
         i = 0
+        new_tools = []
         if not self.is_nbhd_project:
             for tool, label in anchored_tools.iteritems():
                 if tool not in installed_tools:
                     try:
-                        self.install_app(tool, tool, label, i)
+                        new_tools.append(self.install_app(tool, tool, label, i))
                     except Exception:
                         log.error('%s is not available' % tool, exc_info=True)
                 i += 1
+        return new_tools
 
     def grouped_navbar_entries(self):
         """Return a ``allura.app.SitemapEntry`` list suitable for rendering

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/be42517f/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 0c02e06..9a1738a 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -132,6 +132,11 @@ class TestNeighborhood(TestController):
         assert 'error' in self.webflash(r)
         assert_equal(neighborhood.anchored_tools, 'wiki:Wiki, tickets:Ticket')
 
+        r = self.app.get('/p/test/admin/overview')
+        top_nav = r.html.find(id='top_nav')
+        assert top_nav.find(href='/p/test/wiki/'), top_nav
+        assert top_nav.find(href='/p/test/tickets/'), top_nav
+
         r = self.app.get('/p/test/admin/tools')
         assert '<div class="fleft isnt_sorted">' in r
         delete_tool = r.html.find('a', {'class':'mount_delete'})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/be42517f/Allura/allura/tests/model/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_project.py b/Allura/allura/tests/model/test_project.py
index fab054c..064901f 100644
--- a/Allura/allura/tests/model/test_project.py
+++ b/Allura/allura/tests/model/test_project.py
@@ -11,7 +11,7 @@ from allura.lib import helpers as h
 from allura.tests import decorators as td
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura.lib.exceptions import ToolError
-from mock import Mock
+from mock import MagicMock
 
 
 def setUp():
@@ -74,7 +74,7 @@ def test_subproject():
 @td.with_wiki
 def test_anchored_tools():
     c.project.neighborhood.anchored_tools = 'wiki:Wiki, tickets:Ticket'
-    c.project.install_app = Mock()
+    c.project.install_app = MagicMock()
     assert c.project.sitemap()[0].label == 'Wiki'
     assert c.project.install_app.call_args[0][0] == 'tickets'
     assert c.project.ordered_mounts()[0]['ac'].tool_name == 'Wiki'


Mime
View raw message