[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - absIInterfaceService.py:1.1.2.1 service.py:1.2.26.2 test_interfaceservice.py:1.5.2.1 test_nextservice.py:1.5.10.2 test_servicemanagercontainer.py:1.5.10.2
Albertas Agejevas
alga@codeworks.lt
Mon, 23 Jun 2003 10:20:54 -0400
Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv16963/src/zope/app/component/tests
Modified Files:
Tag: cw-mail-branch
service.py test_interfaceservice.py test_nextservice.py
test_servicemanagercontainer.py
Added Files:
Tag: cw-mail-branch
absIInterfaceService.py
Log Message:
One more sync with HEAD.
=== Added File Zope3/src/zope/app/component/tests/absIInterfaceService.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""Abstract test class for IInterfaceService."""
from zope.component.exceptions import ComponentLookupError
from zope.app.interfaces.component import IInterfaceService
from zope.interface import Interface
from zope.interface.verify import verifyObject
class B(Interface):
pass
class I(Interface):
"""bah blah
"""
class I2(B):
"""eek
"""
class I3(B):
"""
"""
def one():
"""method one"""
def two():
"""method two"""
class IInterfaceServiceTests:
def getServices(self):
# Return pair of services, one to query, one to update.
raise NotImplementedError
def testVerifyIInterfaceService(self):
verifyObject(IInterfaceService, self.getServices()[0])
def listEq(self, iterable, expectedlist):
self.assertEqual(list(iterable), expectedlist)
def testInterfaceService(self):
rservice, wservice = self.getServices()
self.assertRaises(ComponentLookupError,
rservice.getInterface, 'Foo.Bar')
self.assertEqual(rservice.queryInterface('Foo.Bar'), None)
self.assertEqual(rservice.queryInterface('Foo.Bar', 42), 42)
self.failIf(rservice.searchInterface(''))
wservice.provideInterface('Foo.Bar', I)
self.assertEqual(rservice.getInterface('Foo.Bar'), I)
self.assertEqual(rservice.queryInterface('Foo.Bar'), I)
self.listEq(rservice.searchInterface(''), [I])
self.listEq(rservice.searchInterface(base=B), [])
wservice.provideInterface('Foo.Baz', I2)
result = list(rservice.searchInterface(''))
result.sort()
self.assertEqual(result, [I, I2])
self.listEq(rservice.searchInterface('I2'), [I2])
self.listEq(rservice.searchInterface('eek'), [I2])
self.listEq(rservice.searchInterfaceIds('I2'), ['Foo.Baz'])
self.listEq(rservice.searchInterfaceIds('eek'), ['Foo.Baz'])
self.listEq(rservice.items("I2"), [("Foo.Baz", I2)])
self.listEq(rservice.items("eek"), [("Foo.Baz", I2)])
wservice.provideInterface('Foo.Bus', I3)
self.listEq(rservice.searchInterface('two'), [I3])
self.listEq(rservice.searchInterface('two', base=B), [I3])
self.listEq(rservice.items("two", base=B), [("Foo.Bus", I3)])
r = list(rservice.searchInterface(base=B))
r.sort()
self.assertEqual(r, [I2, I3])
=== Zope3/src/zope/app/component/tests/service.py 1.2.26.1 => 1.2.26.2 ===
=== Zope3/src/zope/app/component/tests/test_interfaceservice.py 1.5 => 1.5.2.1 ===
--- Zope3/src/zope/app/component/tests/test_interfaceservice.py:1.5 Tue May 13 13:08:34 2003
+++ Zope3/src/zope/app/component/tests/test_interfaceservice.py Mon Jun 23 10:19:53 2003
@@ -11,88 +11,26 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+import unittest
+
from zope.interface import Interface
-from unittest import TestCase, TestSuite, main, makeSuite
-from zope.testing.cleanup import CleanUp
+
from zope.app.interfaces.component import IGlobalInterfaceService
from zope.app.component.globalinterfaceservice import InterfaceService
+from zope.app.component.tests.absIInterfaceService \
+ import IInterfaceServiceTests
+
from zope.interface.verify import verifyObject
-from zope.component.exceptions import ComponentLookupError
-class B(Interface):
- pass
+class Test(IInterfaceServiceTests, unittest.TestCase):
+ """Test Interface for InterfaceService Instance."""
-class I(Interface):
- """bah blah
- """
-
-class I2(B):
- """eek
- """
-
-class I3(B):
- """
- """
- def one():
- """method one"""
-
- def two():
- """method two"""
-
-class Test(CleanUp, TestCase):
- """Test Interface for InterfaceService Instance.
- """
+ def getServices(self):
+ s = InterfaceService()
+ return s, s
def testInterfaceVerification(self):
-
verifyObject(IGlobalInterfaceService, InterfaceService())
- def testInterfaceService(self):
- service = InterfaceService()
-
- self.assertRaises(ComponentLookupError,
- service.getInterface, 'Foo.Bar')
- self.assertEqual(service.queryInterface('Foo.Bar'), None)
- self.assertEqual(service.queryInterface('Foo.Bar', 42), 42)
- self.failIf(service.searchInterface(''))
-
- service.provideInterface('Foo.Bar', I)
-
- self.assertEqual(service.getInterface('Foo.Bar'), I)
- self.assertEqual(service.queryInterface('Foo.Bar'), I)
- self.assertEqual(list(service.searchInterface('')), [I])
- self.assertEqual(list(service.searchInterface(base=B)), [])
-
- service.provideInterface('Foo.Baz', I2)
-
- result = list(service.searchInterface(''))
- result.sort()
- self.assertEqual(result, [I, I2])
-
- self.assertEqual(list(service.searchInterface('I2')), [I2])
- self.assertEqual(list(service.searchInterface('eek')), [I2])
-
- self.assertEqual(list(service.searchInterfaceIds('I2')), ['Foo.Baz'])
- self.assertEqual(list(service.searchInterfaceIds('eek')), ['Foo.Baz'])
-
- service.provideInterface('Foo.Bus', I3)
- self.assertEqual(list(service.searchInterface('two')), [I3])
- self.assertEqual(list(service.searchInterface('two', base=B)), [I3])
-
- r = list(service.searchInterface(base=B))
- r.sort()
- self.assertEqual(r, [I2, I3])
-
def test_suite():
- return TestSuite((makeSuite(Test),))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
- self.assertEqual(list(service.searchInterface('two')), [I3])
-
-
-def test_suite():
- return TestSuite((makeSuite(Test),))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
+ return unittest.makeSuite(Test)
=== Zope3/src/zope/app/component/tests/test_nextservice.py 1.5.10.1 => 1.5.10.2 ===
=== Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py 1.5.10.1 => 1.5.10.2 ===