[Zope-Checkins] SVN: Zope/branches/2.12/src/Products/SiteAccess/tests/testAccessRule.py Add tests for 'Products.SiteAccess.AccessRule.getAccessRule'.
Tres Seaver
tseaver at palladion.com
Fri May 21 09:16:39 EDT 2010
Log message for revision 112608:
Add tests for 'Products.SiteAccess.AccessRule.getAccessRule'.
Changed:
U Zope/branches/2.12/src/Products/SiteAccess/tests/testAccessRule.py
-=-
Modified: Zope/branches/2.12/src/Products/SiteAccess/tests/testAccessRule.py
===================================================================
--- Zope/branches/2.12/src/Products/SiteAccess/tests/testAccessRule.py 2010-05-21 13:16:37 UTC (rev 112607)
+++ Zope/branches/2.12/src/Products/SiteAccess/tests/testAccessRule.py 2010-05-21 13:16:39 UTC (rev 112608)
@@ -172,6 +172,30 @@
self.assertEqual(new_rule.icon, 'misc_/SiteAccess/AccessRule.gif')
+class Test_getAccessRule(unittest.TestCase):
+
+ def _callFUT(self, container, REQUEST=None):
+ from Products.SiteAccess.AccessRule import getAccessRule
+ return getAccessRule(container, REQUEST)
+
+ def test_no_rules(self):
+ container = DummyContainer()
+ self.assertEqual(self._callFUT(container), '')
+
+ def test_w_rule_invalid(self):
+ from ZPublisher.BeforeTraverse import registerBeforeTraverse
+ container = DummyContainer()
+ registerBeforeTraverse(container, DummyObject(), 'AccessRule')
+ self.failUnless(self._callFUT(container).startswith(
+ 'Invalid BeforeTraverse data: '))
+
+ def test_w_rule_valid(self):
+ from ZPublisher.BeforeTraverse import registerBeforeTraverse
+ container = DummyContainer()
+ registerBeforeTraverse(container, DummyObject(name='foo'), 'AccessRule')
+ self.assertEqual(self._callFUT(container), 'foo')
+
+
class DummyRequest(dict):
_virtual_root = None
def setVirtualRoot(self, root):
@@ -196,5 +220,6 @@
return unittest.TestSuite((
unittest.makeSuite(AccessRuleTests),
unittest.makeSuite(Test_manage_addAccessRule),
+ unittest.makeSuite(Test_getAccessRule),
))
More information about the Zope-Checkins
mailing list