[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_field.py:1.9

Jim Fulton jim@zope.com
Mon, 30 Jun 2003 12:23:34 -0400


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

Modified Files:
	test_field.py 
Log Message:
Removed unused component location field and associated widgets and
tests.


=== Zope3/src/zope/app/services/tests/test_field.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/services/tests/test_field.py:1.8	Sat Jun  7 01:32:01 2003
+++ Zope3/src/zope/app/services/tests/test_field.py	Mon Jun 30 12:23:34 2003
@@ -25,23 +25,6 @@
 from zope.app.interfaces.services.module import IModuleService
 from zope.component.interfaces import IServiceService
 
-class ModuleService:
-    implements(IModuleService, IServiceService)
-    # I'm lying about implementing IServiceService, but that is needed to get
-    # a ModuleService as a service manager.  (See XXX comment in module.py.)
-    def __init__(self, name=None, component=None):
-        self.lookup = {}
-        if name is not None:
-            self.lookup[name] = component
-    def resolve(self, dotted_name):
-        if self.lookup.has_key(dotted_name):
-            return self.lookup[dotted_name]
-        raise ImportError, dotted_name
-
-    def getService(self, name):
-        from zope.component import getService
-        return getService(None, name)
-
 class I1(Interface):  pass
 
 class C:
@@ -77,70 +60,9 @@
         self.assertRaises(ValidationError, field.validate, u'/folder1/d')
         self.assertRaises(ValidationError, field.validate, u'/folder1/e')
 
-class TestComponentLocation(TestComponentPath):
-
-    def createObjects(self):
-        TestComponentPath.createObjects(self)
-        self.resolver = ModuleService()
-        self.rootFolder.setServiceManager(self.resolver)
-
-    def createFields(self):
-        from zope.app.services.field import ComponentLocation
-
-        folder2 = traverse(self.rootFolder, 'folder2')
-        field = ComponentLocation(type=I1)
-        field = field.bind(folder2)
-        self.field = field
-        notypefield = ComponentLocation(type=None)
-        notypefield = notypefield.bind(folder2)
-        self.notypefield = notypefield
-
-    def test__validateDottedName(self):
-        field = self.notypefield
-        dotted_name = u'zope.app.whatever.ClassName'
-        some_class = self.__class__
-        self.resolver.lookup[dotted_name] = some_class
-        field._validate(dotted_name)
-        self.assertRaises(ValidationError, field._validate, u'foo.bar.baz')
-
-class TestLocateComponent(PlacefulSetup, TestCase):
-
-    def test_locateComponent(self):
-        from zope.app.services.field import locateComponent
-
-        self.buildFolders()
-        self.folder1.setObject('c', C())
-        self.folder1.setObject('d', D())
-
-        folder2 = traverse(self.rootFolder, 'folder2')
-
-        self.assertEqual(locateComponent(u'/folder1/c', folder2, I1),
-                         traverse(self.rootFolder, '/folder1/c')
-                         )
-        self.assertRaises(ValidationError,
-                          locateComponent, u'/folder1/d', folder2, I1)
-        self.assertRaises(ValidationError,
-                          locateComponent, u'/folder1/e', folder2)
-
-        dotted_name = 'zope.app.whatever.ClassName'
-        some_class = self.__class__
-        resolver = ModuleService(dotted_name, some_class)
-        self.rootFolder.setServiceManager(resolver)
-
-        # We have to re-traverse to get new wrappers, since the old
-        # wrappers have stale caches.
-        folder2 = traverse(self.rootFolder, 'folder2')
-
-        self.assertEqual(locateComponent(dotted_name, folder2),
-                         some_class
-                         )
-        self.assertRaises(ValidationError, locateComponent, 'f.b.b', folder2)
-
 def test_suite():
     return TestSuite((
         makeSuite(TestComponentPath),
-        makeSuite(TestComponentLocation),
-        makeSuite(TestLocateComponent),
         ))
 
 if __name__=='__main__':