[Zope3-checkins] CVS: Zope3/src/zope/component/tests - __init__.py:1.2 components.py:1.2 factory.py:1.2 placelesssetup.py:1.2 request.py:1.2 test_api.py:1.2 test_providefactory.py:1.2 test_resources.py:1.2 test_service.py:1.2 test_skins.py:1.2 test_utilityservice.py:1.2 views.py:1.2

Jim Fulton jim@zope.com
Wed, 25 Dec 2002 09:14:04 -0500


Update of /cvs-repository/Zope3/src/zope/component/tests
In directory cvs.zope.org:/tmp/cvs-serv15352/src/zope/component/tests

Added Files:
	__init__.py components.py factory.py placelesssetup.py 
	request.py test_api.py test_providefactory.py 
	test_resources.py test_service.py test_skins.py 
	test_utilityservice.py views.py 
Log Message:
Grand renaming:

- Renamed most files (especially python modules) to lower case.

- Moved views and interfaces into separate hierarchies within each
  project, where each top-level directory under the zope package
  is a separate project.

- Moved everything to src from lib/python.

  lib/python will eventually go away. I need access to the cvs
  repository to make this happen, however.

There are probably some bits that are broken. All tests pass
and zope runs, but I haven't tried everything. There are a number
of cleanups I'll work on tomorrow.



=== Zope3/src/zope/component/tests/__init__.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:03 2002
+++ Zope3/src/zope/component/tests/__init__.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/component/tests/components.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:03 2002
+++ Zope3/src/zope/component/tests/components.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__metaclass__ = type # All classes are new style when run with Python 2.2+
+
+from zope.interface import Interface
+from zope.interface import Attribute
+
+class IApp(Interface):
+    a = Attribute('test attribute')
+    def f(): "test func"
+
+class IContent(Interface): pass
+
+class Content: __implements__ = IContent
+
+class Comp:
+    __used_for__ = IContent
+    __implements__ = IApp
+
+    a=1
+    def f(): pass
+
+comp = Comp()


=== Zope3/src/zope/component/tests/factory.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:03 2002
+++ Zope3/src/zope/component/tests/factory.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+from zope.component.interfaces import IFactory
+from zope.interface import Interface
+
+class IX(Interface):
+    """the dummy interface which class X supposedly implements,
+    according to the factory"""
+
+class X:
+    __implements__=IX
+    def __init__(self, *args, **kwargs):
+        self.args=args
+        self.kwargs=kwargs
+
+
+class ClassFactoryWrapper:
+    __implements__ = IFactory
+    def __init__(self, klass):
+        self.__klass=klass
+    def __call__(self, *args, **kwargs):
+        return self.__klass(*args, **kwargs)
+    def getInterfaces(self):
+        return getattr(self.__klass,'__implements__', None)
+
+f=ClassFactoryWrapper(X)


=== Zope3/src/zope/component/tests/placelesssetup.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:03 2002
+++ Zope3/src/zope/component/tests/placelesssetup.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+Revision information:
+$Id$
+"""
+
+# A mix-in class inheriting from CleanUp that also connects the CA services
+
+from zope.testing.cleanup import CleanUp
+from zope.component import getServiceManager
+
+class PlacelessSetup(CleanUp):
+    def setUp(self):
+        CleanUp.setUp(self)
+        sm=getServiceManager(None)
+        defineService=sm.defineService
+        provideService=sm.provideService
+        # factory service
+        from zope.component.interfaces import IFactoryService
+        defineService('Factories',IFactoryService)
+        from zope.component.factory import factoryService
+        provideService('Factories', factoryService)
+        # utility service
+        from zope.component.interfaces import IUtilityService
+        defineService('Utilities',IUtilityService)
+        from zope.component.utility import utilityService
+        provideService('Utilities', utilityService)
+        # adapter service
+        from zope.component.interfaces import IAdapterService
+        defineService('Adapters',IAdapterService)
+        from zope.component.adapter import adapterService
+        provideService('Adapters', adapterService)
+        # resource service
+        from zope.component.interfaces import IResourceService
+        defineService('Resources',IResourceService)
+        from zope.component.resource import resourceService
+        provideService('Resources', resourceService)
+        # skin service
+        from zope.component.interfaces import ISkinService
+        defineService('Skins',ISkinService)
+        from zope.component.skin import skinService
+        provideService('Skins', skinService)
+        # view service
+        from zope.component.interfaces import IViewService
+        defineService('Views',IViewService)
+        from zope.component.view import viewService
+        provideService('Views', viewService)
+    def tearDown(self):
+        CleanUp.tearDown(self)


=== Zope3/src/zope/component/tests/request.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:03 2002
+++ Zope3/src/zope/component/tests/request.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+class Request:
+
+    def __init__(self, iface, skin=''):
+        self._iface     = iface
+        self._skin      = skin
+
+    def getPresentationSkin(self):
+        '''See interface IPresentationRequest'''
+
+        return self._skin
+
+    def getPresentationType(self):
+        '''See interface IPresentationRequest'''
+
+        return self._iface


=== Zope3/src/zope/component/tests/test_api.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_api.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,338 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest, sys
+from zope.interface import Interface
+from zope.component.tests.request import Request
+
+
+class I1(Interface): pass
+class I2(Interface): pass
+class I3(Interface): pass
+class Comp:
+    __implements__ = I2
+    def __init__(self, context, request=None): self.context = context
+class Comp2:
+    __implements__ = I3
+    def __init__(self, context, request=None): self.context = context
+
+comp = Comp(1)
+
+class Ob:
+    __implements__ = I1
+
+ob = Ob()
+
+
+class R1(Interface): pass
+class R12(Interface): pass
+class R2(R1): pass
+class R3(R2): pass
+class R4(R3): pass
+
+class P1(Interface): pass
+class P2(P1): pass
+class P3(P2): pass
+class P4(P3): pass
+
+class default_P3: pass
+class any_P3: pass
+class R2_P3: pass
+
+from zope.component.tests.placelesssetup import PlacelessSetup
+
+class Test(PlacelessSetup, unittest.TestCase):
+
+    def testAdapter(self):
+        from zope.component \
+             import getAdapter, getService, queryAdapter
+        from zope.component.exceptions import ComponentLookupError
+
+        # if an object implements the interface you want to adapt to,
+        # getAdapter should simply return the object
+        self.assertEquals(getAdapter(ob, I1), ob)
+
+        # if an adapter isn't registered for the given object and interface,
+        # and you provide no default, raise ComponentLookupError...
+        self.assertRaises(ComponentLookupError, getAdapter, ob, I2)
+
+        # ...otherwise, you get the default
+        self.assertEquals(queryAdapter(ob, I2, Test), Test)
+
+        getService(None, 'Adapters').provideAdapter(I1, I2, Comp)
+        c = getAdapter(ob, I2)
+        self.assertEquals(c.__class__, Comp)
+        self.assertEquals(c.context, ob)
+
+    def testNamedAdapter(self):
+
+        self.testAdapter()
+
+        from zope.component \
+             import getAdapter, getService, queryAdapter
+        from zope.component.exceptions import ComponentLookupError
+
+        # if an object implements the interface you want to adapt to,
+        # getAdapter should simply return the object UNLESS we are sking for a
+        # names adapter.
+        self.assertRaises(ComponentLookupError, getAdapter, ob, I1, 'test')
+
+        # if an adapter isn't registered for the given object and interface,
+        # and you provide no default, raise ComponentLookupError...
+        self.assertRaises(ComponentLookupError, getAdapter, ob, I2, 'test')
+
+        # ...otherwise, you get the default
+        self.assertEquals(queryAdapter(ob, I2, Test, name='test'), Test)
+
+        class Comp2(Comp): pass
+
+        getService(None, 'Adapters').provideAdapter(I1, I2, Comp2, name='test')
+        c = getAdapter(ob, I2, name='test')
+        self.assertEquals(c.__class__, Comp2)
+        self.assertEquals(c.context, ob)
+
+    def testMultipleAdapterFactories(self):
+        from zope.component import getAdapter, getService
+
+        # Basically, this represents a 2-stage adaptation. You can get
+        # from I1 to I2 by way of adapter Comp adapting Comp2
+        getService(None, 'Adapters').provideAdapter(I1, I2, [Comp2, Comp])
+        c = getAdapter(ob, I2)
+        self.assertEquals(c.__class__, Comp)
+        self.assertEquals(c.context.context, ob)
+
+    def testAdapterForInterfaceNone(self):
+        from zope.component import getAdapter, getService
+
+        # providing an adapter for None says that your adapter can
+        # adapt anything to I2.
+        getService(None, 'Adapters').provideAdapter(None, I2, Comp)
+        c = getAdapter(ob, I2)
+        self.assertEquals(c.__class__, Comp)
+        self.assertEquals(c.context, ob)
+
+    def testUtility(self):
+        from zope.component import getUtility, queryUtility
+        from zope.component import getService
+        from zope.component.exceptions import ComponentLookupError
+
+        self.assertRaises(ComponentLookupError, getUtility, ob, I1)
+        self.assertRaises(ComponentLookupError, getUtility, ob, I2)
+        self.assertEquals(queryUtility(ob, I2, Test), Test)
+
+        getService(None, 'Utilities').provideUtility(I2, comp)
+        self.assertEquals(id(getUtility(ob, I2)), id(comp))
+
+    def testNamedUtility(self):
+        from zope.component import getUtility, queryUtility
+        from zope.component import getService
+        from zope.component.exceptions import ComponentLookupError
+
+        self.testUtility()
+
+        self.assertRaises(ComponentLookupError, getUtility, ob, I1, 'test')
+        self.assertRaises(ComponentLookupError, getUtility, ob, I2, 'test')
+        self.assertEquals(queryUtility(ob, I2, Test, 'test'), Test)
+
+        getService(None, 'Utilities').provideUtility(I2, comp, 'test')
+        self.assertEquals(id(getUtility(ob, I2, 'test')), id(comp))
+
+    def testView(self):
+        from zope.component import getView, queryView, getService
+        from zope.component.exceptions import ComponentLookupError
+
+        self.assertRaises(ComponentLookupError,
+                          getView, ob, 'foo', Request(I1))
+        self.assertRaises(ComponentLookupError,
+                          getView, ob, 'foo', Request(I2))
+        self.assertEquals(queryView(ob, 'foo', Request(I2), Test), Test)
+
+        getService(None, 'Views').provideView(I1, 'foo', I2, [Comp])
+        c = getView(ob, 'foo', Request(I2))
+        self.assertEquals(c.__class__, Comp)
+        self.assertEquals(c.context, ob)
+
+        self.assertRaises(ComponentLookupError,
+                          getView, ob, 'foo2', Request(I1))
+        self.assertRaises(ComponentLookupError,
+                          getView, ob, 'foo2', Request(I2))
+        self.assertEquals(queryView(ob, 'foo2', Request(I2), Test), Test)
+
+        self.assertEquals(queryView( ob, 'foo2', Request(I1), None), None)
+
+    def testDefaultViewName(self):
+        from zope.component import getService
+        from zope.exceptions import NotFoundError
+        viewService = getService(None, 'Views')
+        self.assertRaises(NotFoundError,
+                          viewService.getDefaultViewName,
+                          ob, Request(I1))
+        viewService.setDefaultViewName(I1, I2, 'sample_name')
+        self.assertEquals(viewService.getDefaultViewName(ob, Request(I2)),
+                          'sample_name')
+        self.assertRaises(NotFoundError,
+                          viewService.getDefaultViewName,
+                          ob, Request(I1))
+
+
+
+
+    # The following tests are copied from
+    # Interface.Registry.tests.IAdapterRegistry
+
+
+    def __registery(self):
+        from zope.component.adapter \
+             import GlobalAdapterService
+
+        registry = GlobalAdapterService()
+
+
+        registry.provideAdapter(None, P3, [default_P3])
+        registry.provideAdapter(Interface, P3, [any_P3])
+        registry.provideAdapter(R2, P3, [R2_P3])
+
+        return registry
+
+
+    def test_getRegisteredMatching_all(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching())
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_for_R1(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            for_interfaces = (R1, )
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_for_multiple(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            for_interfaces = (R12, R2)
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_provided_P1(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            provided_interfaces = (P1, )
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_provided_P2(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            provided_interfaces = (P3, )
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_for_and_provided_1(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            for_interfaces = (R4, R12),
+            provided_interfaces = (P1, ),
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+    def test_getRegisteredMatching_for_and_provided_2(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            for_interfaces = (R4, R12),
+            provided_interfaces = (P3, ),
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+
+    def test_getRegisteredMatching_for_and_provided_exact(self):
+        registry = self.__registery()
+
+        got = list(registry.getRegisteredMatching(
+            for_interfaces = (R2, ),
+            provided_interfaces = (P3, ),
+            ))
+        got.sort()
+        expect = [
+            ('', None, P3, [default_P3]),
+            ('', Interface, P3, [any_P3]),
+            ('', R2, P3, [R2_P3]),
+            ]
+        expect.sort()
+        self.assertEqual(got, expect)
+
+
+
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/component/tests/test_providefactory.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_providefactory.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test the provideFactory method.
+
+$Id$
+"""
+
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from zope.component.tests.placelesssetup import PlacelessSetup
+
+
+class ProvideFactoryTestCase(PlacelessSetup, TestCase):
+
+    def test_provide_factory(self):
+        from zope.component import getService, createObject
+        from zope.component.tests.factory import f, X, IX
+        factories=getService(None, 'Factories')
+        factories.provideFactory("Some.Object", f)
+        thing = createObject(None,"Some.Object")
+        self.assert_(isinstance(thing, X))
+
+
+def test_suite():
+    return makeSuite(ProvideFactoryTestCase)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/component/tests/test_resources.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_resources.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,85 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest, sys
+
+from zope.component import getService
+from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component import getResource, queryResource
+from zope.component.exceptions import ComponentLookupError
+from zope.interface import Interface
+from zope.component.tests.request import Request
+
+class Test(PlacelessSetup, unittest.TestCase):
+
+    def testSkin(self):
+        class I2(Interface): pass
+        class C1:
+            def __init__(self, request): pass
+            __implements__ = I2
+        class C2(C1): pass
+
+        getService(None,'Resources').provideResource('test', I2, C1)
+        self.assertEqual(getResource(None, 'test', Request(I2)).__class__, C1)
+        getService(None,'Skins').defineSkin('foo', I2, ('foo', 'default'))
+        self.assertEqual(
+            getResource(None, 'test', Request(I2, 'foo')).__class__,
+            C1)
+        getService(None,'Resources').provideResource('test', I2, C2,
+                                                     layer='foo')
+        self.assertEqual(
+            getResource(None, 'test', Request(I2, 'foo')).__class__,
+            C2)
+
+    def testGetRequestResourceMethod(self):
+        class I2(Interface): pass
+        class C1:
+            def __init__(self, request): pass
+
+            __implements__ = I2
+        class C2(C1): pass
+
+
+        getService(None,'Resources').provideResource('test', I2, C1)
+        self.assertEqual(
+            getResource(None, 'test', Request(I2, 'default') ).__class__,
+            C1)
+        getService(None,'Skins').defineSkin('foo', I2, ('foo', 'default'))
+        self.assertEqual(
+            getResource(None, 'test', Request(I2, 'foo')).__class__,
+            C1)
+        getService(None,'Resources').provideResource('test', I2, C2,
+                                                     layer='foo')
+        self.assertEqual(
+            getResource(None, 'test', Request(I2, 'foo')).__class__,
+            C2)
+
+        self.assertRaises(
+            ComponentLookupError,
+            getResource, None, 'test2', Request(I2, 'foo'))
+
+        self.assertEqual(
+            queryResource(None, 'test2', Request(I2, 'foo'), None),
+            None)
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/component/tests/test_service.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_service.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,119 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest
+from zope.interface import Interface
+
+from zope.exceptions import DuplicationError
+from zope.testing.cleanup import CleanUp
+
+from zope.component \
+     import getServiceDefinitions, getService, getServiceManager
+from zope.component.service \
+     import UndefinedService, InvalidService
+from zope.component.exceptions import ComponentLookupError
+
+from zope.component import queryService
+
+class IOne(Interface):
+    pass
+
+class ITwo(Interface):
+    pass
+
+class ServiceOne:
+    __implements__ = IOne
+
+class ServiceTwo:
+    __implements__ = ITwo
+
+class Test(CleanUp, unittest.TestCase):
+
+    def testNormal(self):
+        getServiceManager(None).defineService('one', IOne)
+        c = ServiceOne()
+        getServiceManager(None).provideService('one', c)
+        self.assertEqual(id(getService(None, 'one')), id(c))
+
+    def testFailedLookup(self):
+        self.assertRaises(ComponentLookupError, getService, None, 'two')
+        self.assertEqual(queryService(None, 'two'), None)
+
+    def testDup(self):
+        getServiceManager(None).defineService('one', IOne)
+        self.assertRaises(DuplicationError,
+                          getServiceManager(None).defineService,
+                          'one', ITwo)
+
+        c = ServiceOne()
+        getServiceManager(None).provideService('one', c)
+
+        c2 = ServiceOne()
+        self.assertRaises(DuplicationError,
+                          getServiceManager(None).provideService,
+                          'one', c2)
+
+        self.assertEqual(id(getService(None, 'one')), id(c))
+
+
+    def testUndefined(self):
+        c = ServiceOne()
+        self.assertRaises(UndefinedService,
+                          getServiceManager(None).provideService,
+                          'one', c)
+
+    def testInvalid(self):
+        getServiceManager(None).defineService('one', IOne)
+        getServiceManager(None).defineService('two', ITwo)
+        c = ServiceOne()
+        self.assertRaises(InvalidService,
+                          getServiceManager(None).provideService,
+                          'two', c)
+
+    def testGetService(self):
+        # Testing looking up a service from a service manager container that
+        # doesn't have a service manager.
+        getServiceManager(None).defineService('one', IOne)
+        c = ServiceOne()
+        getServiceManager(None).provideService('one', c)
+        class C: pass
+        foo = C()
+        self.assertEqual(id(getService(foo, 'one')), id(c))
+
+    def testGetServiceDefinitions(self):
+        # test that the service definitions are the ones we added
+        getServiceManager(None).defineService('one', IOne)
+        c = ServiceOne()
+        getServiceManager(None).provideService('one', c)
+
+        getServiceManager(None).defineService('two', ITwo)
+        d = ServiceTwo()
+        getServiceManager(None).provideService('two', d)
+        defs = getServiceDefinitions(None)
+        defs.sort()
+        self.assertEqual(defs,
+            [('one', IOne), ('two', ITwo)])
+
+
+def test_suite():
+    loader = unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+
+if __name__ == '__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/component/tests/test_skins.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_skins.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest, sys
+
+from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component import getView, getService, queryView
+from zope.component.exceptions import ComponentLookupError
+from zope.interface import Interface
+from zope.component.tests.request import Request
+
+
+class Test(PlacelessSetup, unittest.TestCase):
+
+    def testSkin(self):
+        class I1(Interface): pass
+        class I2(Interface): pass
+
+        class C1:
+            __implements__ = I2
+            __used_for__ = I1
+            def __init__(self, o, request): self._context=o
+        class C2(C1): pass
+        class C3(C1): pass
+
+        class O: __implements__ = I1
+
+        getService(None, 'Views').provideView(I1, 'test', I2, [C1])
+        self.assertEqual(getView(O(), 'test', Request(I2)).__class__, C1)
+        getService(None, 'Skins').defineSkin('foo', I2, ('foo', 'default'))
+        self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+                         C1)
+        getService(None, 'Views').provideView(None, 'test', I2, [C2])
+        self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+                         C1)
+        getService(None, 'Views').provideView(
+            None, 'test', I2, [C2], layer='foo')
+        self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+                         C2)
+        getService(None, 'Views').provideView(
+            I1, 'test', I2, [C3], layer='foo')
+        self.assertEqual(getView(O(), 'test', Request(I2, 'foo')).__class__,
+                         C3)
+
+
+
+    def testGetRequestViewMethod(self):
+
+        class I1(Interface): pass
+        class I2(Interface): pass
+
+        class C1:
+            __implements__ = I2
+            __used_for__ = I1
+            def __init__(self, o, request): self._context=o
+        class C2(C1): pass
+        class C3(C1): pass
+
+        class O: __implements__ = I1
+
+
+        getService(None, 'Views').provideView(I1, 'test', I2, [C1])
+        self.assertEqual(getView(O(), 'test',
+            Request(I2,'') ).__class__, C1)
+        getService(None, 'Skins').defineSkin('foo', I2, ('foo', 'default'))
+
+        self.assertEqual(getView(O(), 'test',
+            Request(I2, 'foo')).__class__, C1)
+        getService(None, 'Views').provideView(None, 'test', I2, [C2])
+
+        self.assertEqual(getView(O(), 'test',
+            Request(I2, 'foo')).__class__, C1)
+        getService(None, 'Views').provideView(
+            None, 'test', I2, [C2], layer='foo')
+
+        self.assertEqual(getView(O(), 'test',
+            Request(I2, 'foo')).__class__, C2)
+        getService(None, 'Views').provideView(
+            I1, 'test', I2, [C3], layer='foo')
+
+        self.assertEqual(getView(O(), 'test',
+            Request(I2, 'foo')).__class__, C3)
+
+        self.assertRaises(ComponentLookupError,
+            getView, O(), 'test2', Request(I2, 'foo'))
+
+        self.assertEqual(queryView(O(), 'test2',
+                                   Request(I2, 'foo'), None), None)
+
+
+
+def test_suite():
+    loader=unittest.TestLoader()
+    return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())


=== Zope3/src/zope/component/tests/test_utilityservice.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/test_utilityservice.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""test utility service
+
+XXX longer description goes here.
+
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from zope.component import \
+     getUtility, getService, queryUtility, getServiceManager
+from zope.component.exceptions import ComponentLookupError
+from zope.interface import Interface
+
+from zope.testing.cleanup import CleanUp # Base class w registry cleanup
+
+class IDummyService(Interface):
+    pass
+
+class DummyService:
+    __implements__ = IDummyService
+
+dummyService = DummyService()
+
+class Test(TestCase, CleanUp):
+    def setUp(self):
+        CleanUp.setUp(self)
+        sm=getServiceManager(None)
+        defineService=sm.defineService
+        provideService=sm.provideService
+        from zope.component.interfaces import IUtilityService
+        defineService('Utilities',IUtilityService)
+        from zope.component.utility import utilityService
+        provideService('Utilities', utilityService)
+
+    def testGetUtility(self):
+        us = getService(None, "Utilities")
+        self.assertRaises(
+            ComponentLookupError, getUtility, None, IDummyService)
+        us.provideUtility(IDummyService, dummyService)
+        self.assertEqual(getUtility(None, IDummyService), dummyService)
+
+    def testQueryUtility(self):
+        us = getService(None, "Utilities")
+        self.assertEqual(queryUtility(None, IDummyService), None)
+        self.assertEqual(queryUtility(None, IDummyService, self), self)
+        us.provideUtility(IDummyService, dummyService)
+        self.assertEqual(queryUtility(None, IDummyService), dummyService)
+
+
+def test_suite():
+    return makeSuite(Test)
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')


=== Zope3/src/zope/component/tests/views.py 1.1 => 1.2 ===
--- /dev/null	Wed Dec 25 09:14:04 2002
+++ Zope3/src/zope/component/tests/views.py	Wed Dec 25 09:13:32 2002
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+Revision information: $Id$
+"""
+
+from zope.interface import Interface
+
+
+class IV(Interface):
+    def index(): pass
+
+class IC(Interface): pass
+
+class V1:
+    __implements__ = IV
+
+    def __init__(self,context, request):
+        self.context = context
+        self.request = request
+
+    def index(self): return 'V1 here'
+
+    def action(self): return 'done'
+
+class VZMI(V1):
+    def index(self): return 'ZMI here'
+
+class R1:
+
+    def index(self): return 'R1 here'
+
+    def action(self): return 'R done'
+
+    def __init__(self, request):
+        pass
+
+    __implements__ = IV
+
+class RZMI(R1):
+    pass