[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_view.py:1.18
Jeremy Hylton
jeremy@zope.com
Mon, 23 Jun 2003 12:20:39 -0400
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv5737/src/zope/app/services/tests
Modified Files:
test_view.py
Log Message:
Implement IInterfaceBasedRegistry for the ViewService.
Add an interface to describe getRegisteredMatching() for the local view service.
zapi-ify the local view service.
setup-ify the local view service tests.
=== Zope3/src/zope/app/services/tests/test_view.py 1.17 => 1.18 ===
--- Zope3/src/zope/app/services/tests/test_view.py:1.17 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_view.py Mon Jun 23 12:20:08 2003
@@ -17,27 +17,34 @@
"""
from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.services.tests.iregistry import TestingIRegistry
-from zope.app.services.view import ViewService
+
from zope.interface import Interface, directlyProvides, implements
+from zope.interface.verify import verifyObject
+
+from zope.app.content.folder import RootFolder
from zope.app.context import ContextWrapper
-from zope.component.exceptions import ComponentLookupError
-from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.interfaces.services.view import IZPTTemplate
from zope.app.services.service import ServiceManager
-from zope.app.services.view import ViewRegistration
-from zope.app.content.folder import RootFolder
+from zope.app.services.servicenames import Views
+from zope.app.services.tests.iregistry import TestingIRegistry
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.services.view \
+ import ViewRegistration, PageRegistration, BoundTemplate, ViewService
+from zope.app.tests import setup
from zope.app.traversing import traverse
+
+from zope.component.exceptions import ComponentLookupError
from zope.component.interfaces import IServiceService
from zope.component.view import provideView
-from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.browser import IBrowserPresentation
-from zope.app.interfaces.services.view import IZPTTemplate
-from zope.app.services.view import PageRegistration, BoundTemplate
-from zope.interface.verify import verifyObject
from zope.component.interfaces import IViewService
-from zope.proxy import removeAllProxies
+
from zope.configuration.exceptions import ConfigurationError
+from zope.proxy import removeAllProxies
+
+from zope.publisher.browser import TestRequest
+from zope.publisher.interfaces.browser import IBrowserPresentation
+
class I1(Interface):
pass
@@ -58,6 +65,7 @@
presentationType = I2
viewName = 'test'
layer = 'default'
+ serviceType = Views
def getView(self, object, request):
return self.factory(object, request)
@@ -81,8 +89,8 @@
class TestViewService(PlacefulSetup, TestingIRegistry, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self, site=True)
- self._service = ContextWrapper(ViewService(), self.rootFolder)
+ sm = PlacefulSetup.setUp(self, site=True)
+ self._service = setup.addService(sm, Views, ViewService())
def test_implements_IViewService(self):
from zope.component.interfaces import IViewService
@@ -126,9 +134,8 @@
sm = traverse(self.rootFolder, '++etc++site')
registration_manager = traverse(sm, 'default').getRegistrationManager()
- registration = Registration()
- registration_manager.setObject('', registration)
- registration = traverse(registration_manager, '1')
+ key = registration_manager.setObject('', Registration())
+ registration = traverse(registration_manager, key)
class O:
implements(I1)
@@ -184,6 +191,14 @@
r = self._service.getRegisteredMatching(*args)
self.assertEqual(list(r), [(I1, I2, registry, 'default', 'test')])
+ def test_getRegistrationsForInterface(self):
+ self.test_queryView_and_getView()
+ for reg in self._service.getRegistrationsForInterface(I1):
+ self.assertEqual(reg.forInterface, I1)
+
+ for reg in self._service.getRegistrationsForInterface(I1E):
+ self.assertEqual(reg.forInterface, I1)
+
class PhonyServiceManager(ServiceManager):
implements(IServiceService)
@@ -276,11 +291,11 @@
def test_suite():
- return TestSuite((
+ return TestSuite([
makeSuite(TestViewService),
makeSuite(TestViewRegistration),
makeSuite(TestPageRegistration),
- ))
+ ])
-if __name__=='__main__':
+if __name__ == '__main__':
main(defaultTest='test_suite')