Skip to content

Commit

Permalink
Implemented ISiteMenu
Browse files Browse the repository at this point in the history
Added more unit tests
  • Loading branch information
projekt01 committed Dec 31, 2007
1 parent de511a9 commit c0151af
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
CHANGES
=======

Note
----

This package is not ready to use because the API will probably change
another time.


Version 0.5.0dev (unreleased)
-----------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/menu/ready2go/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def selected(self):
class SiteMenuItem(MenuItem):
"""Site menu item."""

zope.interface.implements(interfaces.IGlobalMenuItem)
zope.interface.implements(interfaces.ISiteMenuItem)

def getURLContext(self):
return hooks.getSite()
Expand Down
36 changes: 34 additions & 2 deletions src/z3c/menu/ready2go/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"""

import unittest
import zope.interface
import zope.component
from zope.traversing.browser.interfaces import IAbsoluteURL
from zope.traversing.interfaces import IPhysicallyLocatable
from zope.app.component import hooks
from zope.app.testing import setup

Expand All @@ -30,8 +32,18 @@
class ParentStub(object):
"""Just an object supporting a context attribtute."""

context = None
__name__ = None
__name__ = __parent__ = context = None

zope.interface.implements(IPhysicallyLocatable)

def __init__(self, path=('a', 'b')):
self.path = path

def getRoot(self):
return self

def getPath(self):
return self.path


class AbsoulteURLStub(object):
Expand Down Expand Up @@ -73,6 +85,25 @@ def getTestInterface(self):
def getTestClass(self):
return item.GlobalMenuItem

def getTestPos(self):
return (ParentStub(), None, ParentStub(), None)


class SiteMenuItemTest(z3c.testing.InterfaceBaseTest):

def setUp(self):
site = setup.placefulSetUp(site=True)
hooks.setSite(site)
zope.component.provideAdapter(AbsoulteURLStub, (None, None),
IAbsoluteURL)
super(SiteMenuItemTest, self).setUp()

def getTestInterface(self):
return interfaces.ISiteMenuItem

def getTestClass(self):
return item.SiteMenuItem

def getTestPos(self):
return (None, None, ParentStub(), None)

Expand All @@ -93,6 +124,7 @@ def test_suite():
return unittest.TestSuite((
unittest.makeSuite(MenuManagerTest),
unittest.makeSuite(GlobalMenuItemTest),
unittest.makeSuite(SiteMenuItemTest),
unittest.makeSuite(ContextMenuItemTest),
))

Expand Down

0 comments on commit c0151af

Please sign in to comment.