[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/browser/tests - test_globalbrowsermenuservice.py:1.11

Richard Jones richard@commonground.com.au
Wed, 9 Jul 2003 21:35:20 -0400


Update of /cvs-repository/Zope3/src/zope/app/publisher/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv2714/tests

Modified Files:
	test_globalbrowsermenuservice.py 
Log Message:
Modified getMenu to correctly identify current view.


=== Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py:1.10	Sat Jun  7 01:46:03 2003
+++ Zope3/src/zope/app/publisher/browser/tests/test_globalbrowsermenuservice.py	Wed Jul  9 21:35:15 2003
@@ -151,6 +151,41 @@
 
         self.assertEqual(list(menu), [d(5), d(6), d(3), d(2), d(1)])
 
+    def test_identify_action(self):
+        r = self.__reg()
+        r.menu('test_id', 'test menu')
+        r.menuItem('test_id', Interface, 'a1', 't1', 'd1')
+        r.menuItem('test_id', I11, 'a12', 't12', 'd12')
+        r.menuItem('test_id', I111, 'a2', 't2', 'd2')
+
+        def d(n, selected=''):
+            return {'action': "a%s" % n,
+                    'title':  "t%s" % n,
+                    'description':  "d%s" % n,
+                    'selected': selected}
+
+        menu = r.getMenu('test_id', X(),
+            TestRequest(SERVER_URL='http://127.0.0.1/a1', PATH_INFO='/a1'))
+        self.assertEqual(list(menu), [d(2), d(12), d(1, 'selected')])
+        menu = r.getMenu('test_id', X(), 
+            TestRequest(SERVER_URL='http://127.0.0.1/a12', PATH_INFO='/a12'))
+        self.assertEqual(list(menu), [d(2), d(12, 'selected'), d(1)])
+        menu = r.getMenu('test_id', X(),
+            TestRequest(SERVER_URL='http://127.0.0.1/@@a1', PATH_INFO='/@@a1'))
+        self.assertEqual(list(menu), [d(2), d(12), d(1, 'selected')])
+        menu = r.getMenu('test_id', X(), 
+            TestRequest(SERVER_URL='http://127.0.0.1/@@a12',
+            PATH_INFO='/@@a12'))
+        self.assertEqual(list(menu), [d(2), d(12, 'selected'), d(1)])
+        menu = r.getMenu('test_id', X(),
+            TestRequest(SERVER_URL='http://127.0.0.1/++view++a1',
+            PATH_INFO='/++view++a1'))
+        self.assertEqual(list(menu), [d(2), d(12), d(1, 'selected')])
+        menu = r.getMenu('test_id', X(), 
+            TestRequest(SERVER_URL='http://127.0.0.1/++view++a12',
+            PATH_INFO='/++view++a12'))
+        self.assertEqual(list(menu), [d(2), d(12, 'selected'), d(1)])
+
     def testEmpty(self):
         r = self.__reg()
         r.menu('test_id', 'test menu')