[Zope3-checkins] CVS: Zope3/src/zope/app/traversing/tests - test_physicallocationadapters.py:1.16

Christian Zagrodnick cvs-admin at zope.org
Sun Dec 7 06:31:15 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv28276/src/zope/app/traversing/tests

Modified Files:
	test_physicallocationadapters.py 
Log Message:
added getNearestSite to IPhysicallyLocatable (and implementations)


=== Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py:1.15	Fri Nov 21 12:12:16 2003
+++ Zope3/src/zope/app/traversing/tests/test_physicallocationadapters.py	Sun Dec  7 06:31:14 2003
@@ -26,13 +26,34 @@
 from zope.app.location import LocationPhysicallyLocatable
 from zope.app.traversing.adapters import RootPhysicallyLocatable
 from zope.app.container.contained import contained
+from zope.component.interfaces import IServiceService
+from zope.app.services.servicecontainer import ServiceManagerContainer
+
 
 class Root:
     implements(IContainmentRoot)
 
+    __parent__ = None
+
+
 class C:
     pass
 
+
+class SiteManager:
+
+    implements(IServiceService)
+
+    def getService(self, object, name):
+        '''See interface IServiceService'''
+        raise ComponentLookupError(name)
+
+    def getServiceDefinitions(self):
+        '''See interface IServiceService'''
+        return ()
+
+
+
 class Test(PlacelessSetup, TestCase):
 
     def test(self):
@@ -43,16 +64,20 @@
 
         root = Root()
         f1 = contained(C(), root, name='f1')
-        f2 = contained(C(),   f1, name='f2')
+        f2 = contained(ServiceManagerContainer(),   f1, name='f2')
         f3 = contained(C(),   f2, name='f3')
-
+        
         adapter = getAdapter(f3, IPhysicallyLocatable)
 
         self.assertEqual(adapter.getPath(), '/f1/f2/f3')
         self.assertEqual(adapter.getName(), 'f3')
         self.assertEqual(adapter.getRoot(), root)
+        self.assertEqual(adapter.getNearestSite(), root)
 
+        f2.setSiteManager(SiteManager())
+        self.assertEqual(adapter.getNearestSite(), f2)
 
+        
 def test_suite():
     return makeSuite(Test)
 




More information about the Zope3-Checkins mailing list