[Checkins] SVN: z3c.menu.ready2go/trunk/ - Reflect latest changes in tests

Roger Ineichen roger at projekt01.ch
Fri Apr 11 08:29:38 EDT 2008


Log message for revision 85239:
  - Reflect latest changes in tests
  - Fixed cssInActive usage. This was broken and ended in 
    not using the cssInActive CSS class argument
  - Added more tests, now we have 100% coverage

Changed:
  U   z3c.menu.ready2go/trunk/CHANGES.txt
  U   z3c.menu.ready2go/trunk/buildout.cfg
  U   z3c.menu.ready2go/trunk/setup.py
  U   z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/README.txt
  U   z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/item.py
  U   z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/tests.py

-=-
Modified: z3c.menu.ready2go/trunk/CHANGES.txt
===================================================================
--- z3c.menu.ready2go/trunk/CHANGES.txt	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/CHANGES.txt	2008-04-11 12:29:38 UTC (rev 85239)
@@ -2,13 +2,7 @@
 CHANGES
 =======
 
-Note
-----
 
-This package is not ready to use because the API will probably change
-another time.
-
-
 Version 0.5.0dev (unreleased)
 -----------------------------
 

Modified: z3c.menu.ready2go/trunk/buildout.cfg
===================================================================
--- z3c.menu.ready2go/trunk/buildout.cfg	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/buildout.cfg	2008-04-11 12:29:38 UTC (rev 85239)
@@ -1,6 +1,6 @@
 [buildout]
 develop = .
-parts = test checker coverage
+parts = test checker coverage-test coverage-report
 
 [test]
 recipe = zc.recipe.testrunner
@@ -10,6 +10,15 @@
 recipe = lovely.recipe:importchecker
 path = src/z3c/menu/ready2go
 
-[coverage]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.menu.ready2go [test]
+defaults = ['--coverage', '../../coverage']
+
+
+[coverage-report]
 recipe = zc.recipe.egg
 eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')

Modified: z3c.menu.ready2go/trunk/setup.py
===================================================================
--- z3c.menu.ready2go/trunk/setup.py	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/setup.py	2008-04-11 12:29:38 UTC (rev 85239)
@@ -51,10 +51,12 @@
     namespace_packages = ['z3c'],
     extras_require = dict(
         test = [
-            'zope.testbrowser',
+            'z3c.testing',
+            'zope.app.container',
+            'zope.app.pagetemplate',
+            'zope.app.testing',
             'zope.component',
-            'zope.app.testing',
-            'z3c.testing',
+            'zope.traversing',
             ],
         ),
     install_requires = [
@@ -63,7 +65,12 @@
         'z3c.template',
         'zope.app.component',
         'zope.app.pagetemplate',
+        'zope.configuration',
+        'zope.interface',
+        'zope.proxy',
+        'zope.publisher',
         'zope.schema',
+        'zope.security',
         'zope.traversing',
         'zope.viewlet',
         ],

Modified: z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/README.txt
===================================================================
--- z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/README.txt	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/README.txt	2008-04-11 12:29:38 UTC (rev 85239)
@@ -170,9 +170,17 @@
   ...     IBrowserView, IGlobalMenu),
   ...     IViewlet, name='My Global')
 
-Now let's render the global menu again. You can see that we ve got a menu item:
+Now let's update the menu manager and see that this manager now contains 
+the menu item:
 
   >>> globalMenu.update()
+  >>> myGlobalMenuItem = globalMenu.viewlets[0]
+  >>> myGlobalMenuItem
+  <MyGlobalMenuItem u'My Global'>
+
+Now let's render the global menu manager and you can see that the menu item
+get rendered:
+
   >>> print globalMenu.render()
   <li>
     <a href="http://127.0.0.1/root.html"><span>My Global</span></a>
@@ -261,7 +269,7 @@
 
   >>> view.__name__ = 'context.html'
 
-Now try again and see if the context menu titem get rendered as selected:
+Now try again and see if the context menu item get rendered as selected:
 
   >>> contextMenu.update()
   >>> print contextMenu.render()
@@ -269,7 +277,73 @@
     <a href="http://127.0.0.1/site/content/context.html"><span>My Context</span></a>
   </li>
 
+Now add a second context menu item and check if we can use the cssInActive
+argument which is normaly a empty string:
 
+  >>> class InActiveMenuItem(ContextMenuItem):
+  ...
+  ...     viewName = 'inActive.html'
+  ...     cssInActive = 'inActive'
+
+  >>> defineChecker(InActiveMenuItem, viewletChecker)
+
+  >>> zope.component.provideAdapter(
+  ...     InActiveMenuItem,
+  ...     (zope.interface.Interface, IDefaultBrowserLayer,
+  ...     IBrowserView, IContextMenu),
+  ...     IViewlet, name='In Active')
+
+Now update and render again:
+
+  >>> contextMenu.update()
+  >>> print contextMenu.render()
+  <li class="selected">
+    <a href="http://127.0.0.1/site/content/context.html"><span>My Context</span></a>
+  </li>
+  <li class="inActive">
+    <a href="http://127.0.0.1/site/content/inActive.html"><span>In Active</span></a>
+  </li>
+
+
+AddMenu
+-------
+
+The add menu can be used for offering links to any kind of add forms per 
+context. This allows us to offer independent add form links doesn't matter which
+form framework is used. Let's now define such a simple AddMenuItem pointing
+to a add form url. Not; the add form and it's url do not exist in thsi test.
+This aslo means there is no guarantee that a form exist if a add menu item
+is configured.
+
+  >>> from z3c.menu.ready2go.item import AddMenuItem
+  >>> class MyAddMenuItem(AddMenuItem):
+  ...
+  ...     viewName = 'addSomething.html'
+
+Now we need a security checker for our menu item
+
+  >>> from zope.security.checker import NamesChecker, defineChecker
+  >>> viewletChecker = NamesChecker(('update', 'render'))
+  >>> defineChecker(MyAddMenuItem, viewletChecker)
+
+And we configure our menu item for IAddMenu. This is normaly done by the
+``viewlet`` ZCML directive:
+
+  >>> zope.component.provideAdapter(
+  ...     MyAddMenuItem,
+  ...     (zope.interface.Interface, IDefaultBrowserLayer,
+  ...     IBrowserView, IAddMenu),
+  ...     IViewlet, name='My AddMenu')
+
+Now we can update and render our add menu:
+
+  >>> addMenu.update()
+  >>> print addMenu.render()
+  <li>
+    <a href="http://127.0.0.1/site/content/addSomething.html"><span>My AddMenu</span></a>
+  </li>
+
+
 Menu groups
 -----------
 
@@ -304,8 +378,32 @@
   <li class="selected">
     <a href="http://127.0.0.1/site/content/context.html"><span>My Context</span></a>
   </li>
+  <li class="inActive">
+    <a href="http://127.0.0.1/site/content/inActive.html"><span>In Active</span></a>
+  </li>
 
 
+EmptyMenuManager
+----------------
+
+There is a empty menu manager whihc could be used for override existing
+menu managers.
+
+  >>> from z3c.menu.ready2go.manager import EmptyMenuManager
+  >>> emptyMenu = EmptyMenuManager(None, None, None)
+
+Our empty menu manager implements IMenuManager:
+
+  >>> interfaces.IMenuManager.providedBy(emptyMenu)
+  True
+
+This empty menu manager returns allways an empty string if we render them:
+
+  >>> emptyMenu.update()
+  >>> emptyMenu.render()
+  u''
+
+
 Special use case
 ----------------
 
@@ -326,24 +424,21 @@
 context and update and render the menus. You can see that the global menu does
 not contain any menu item. That's because the global menu items tries to find
 the root by traversing from the context to the root by the __parent__ chain
-and we don't support any parent for your nirvana object:
+and we don't support any parent for our nirvana object:
 
   >>> globalMenu = GlobalMenu(nirvana, request, nirvanaView)
   >>> globalMenu.update()
   >>> globalMenu.render()
   u''
 
-But you can see that the site menu renders the menu item becyuse we lookup the 
-site by the hooks and we still point to our site we set with setSite():
+Also the SiteMenu doesn't contain any menu item because of the parent less
+object:
 
   >>> siteMenu = SiteMenu(nirvana, request, nirvanaView)
   >>> siteMenu.update()
-  >>> print siteMenu.render()
-  <li class="selected">
-    <a href="http://127.0.0.1/site/site.html"><span>My Site</span></a>
-  </li>
+  >>> siteMenu.render()
+  u''
 
-
   >>> contextMenu = ContextMenu(nirvana, request, nirvanaView)
   >>> contextMenu.update()
   >>> contextMenu.render()

Modified: z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/item.py
===================================================================
--- z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/item.py	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/item.py	2008-04-11 12:29:38 UTC (rev 85239)
@@ -85,11 +85,11 @@
     def css(self):
         """Return cssActive, cssInActive or None. 
 
-        None will not render a HTML attribute in TAL.
+        None will force not rendering a HTML attribute in the element tag.
         """
         if self.selected and self.cssActive:
             return self.cssActive
-        elif self.selected and self.cssInActive:
+        elif not self.selected and self.cssInActive:
             return self.cssInActive
         else:
             return None

Modified: z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/tests.py
===================================================================
--- z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/tests.py	2008-04-11 12:25:39 UTC (rev 85238)
+++ z3c.menu.ready2go/trunk/src/z3c/menu/ready2go/tests.py	2008-04-11 12:29:38 UTC (rev 85239)
@@ -131,7 +131,7 @@
         return item.SiteMenuItem
 
     def getTestPos(self):
-        return (None, None, ParentStub(), None)
+        return (ParentStub(), None, ParentStub(), None)
 
 
 class ContextMenuItemTest(z3c.testing.InterfaceBaseTest):



More information about the Checkins mailing list