[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_pagefolder.py:1.7
Jim Fulton
jim@zope.com
Wed, 2 Jul 2003 18:11:12 -0400
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv380/src/zope/app/services/tests
Modified Files:
test_pagefolder.py
Log Message:
Added an applyDefaults method to apply default settings to existing
page registrations.
=== Zope3/src/zope/app/services/tests/test_pagefolder.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_pagefolder.py:1.6 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_pagefolder.py Wed Jul 2 18:11:08 2003
@@ -35,20 +35,29 @@
class I(Interface):
pass
+class I2(Interface):
+ pass
+
class Test(RegistrationManagerContainerTests, PlacefulSetup, TestCase):
- def test_setObject(self):
+ def setUp(self):
+ sm = PlacefulSetup.setUp(self, site=True)
provideAdapter(IPageFolder, IZopeContextWrapper,
PageFolderContextDecorator)
- sm = self.buildFolders(site=True)
setup.addService(sm, 'Views', ViewService(), suffix='service')
-
default = traverse(self.rootFolder, '++etc++site/default')
default.setObject('Views', PageFolder())
views = traverse(default, 'Views')
views.forInterface = I
views.factoryName = None
views.permission = 'zope.View'
+
+ self.__views = views
+
+ def test_setObject(self):
+
+ views = self.__views
+
views.setObject('foo.html', ZPTTemplate())
registration = traverse(views.getRegistrationManager(), '1')
@@ -64,6 +73,39 @@
self.assertRaises(TypeError,
views.setObject, 'bar.html', PageFolder())
+ def test_applyDefaults(self):
+
+ views = self.__views
+
+ views.setObject('foo.html', ZPTTemplate())
+
+ registration = traverse(views.getRegistrationManager(), '1')
+ self.assertEqual(registration.status, ActiveStatus)
+ self.assertEqual(registration.forInterface, I)
+ self.assertEqual(registration.presentationType, IBrowserPresentation)
+ self.assertEqual(registration.viewName, u'foo.html')
+ self.assertEqual(registration.layer, 'default')
+ self.assertEqual(registration.class_, None)
+ self.assertEqual(registration.permission, 'zope.View')
+ self.assertEqual(registration.attribute, None)
+
+ views.forInterface = I2
+ views.permission = 'zope.ManageContent'
+ views.layer = 'debug'
+
+ views.applyDefaults()
+
+ registration = traverse(views.getRegistrationManager(), '1')
+ self.assertEqual(registration.status, ActiveStatus)
+ self.assertEqual(registration.forInterface, I2)
+ self.assertEqual(registration.presentationType, IBrowserPresentation)
+ self.assertEqual(registration.viewName, u'foo.html')
+ self.assertEqual(registration.layer, 'debug')
+ self.assertEqual(registration.class_, None)
+ self.assertEqual(registration.permission, 'zope.ManageContent')
+ self.assertEqual(registration.attribute, None)
+
+
def test_suite():
return TestSuite((