[Zodb-checkins] CVS: Zope3/lib/python/Interface/Registry/tests - TestIAdapterRegistry.py:1.2.8.3
Jim Fulton
jim@zope.com
Thu, 24 Oct 2002 01:52:07 -0400
Update of /cvs-repository/Zope3/lib/python/Interface/Registry/tests
In directory cvs.zope.org:/tmp/cvs-serv23537/lib/python/Interface/Registry/tests
Modified Files:
Tag: Zope3-Bangalore-TTW-Branch
TestIAdapterRegistry.py
Log Message:
Made interfaces sortable. I'd prefer that interfaces be sorted from
mosy specific to most general, but this was harder than I'd hoped, so,
for now, we just sort on name. :/
Added an initial adapter registery API to get registration information
that matches given interface specifications.
=== Zope3/lib/python/Interface/Registry/tests/TestIAdapterRegistry.py 1.2.8.2 => 1.2.8.3 ===
--- Zope3/lib/python/Interface/Registry/tests/TestIAdapterRegistry.py:1.2.8.2 Wed Oct 16 04:35:35 2002
+++ Zope3/lib/python/Interface/Registry/tests/TestIAdapterRegistry.py Thu Oct 24 01:52:05 2002
@@ -146,8 +146,94 @@
self.assertEqual(registry.getRegistered(R3, P3), None)
self.assertEqual(registry.getRegistered(R2, P2), None)
-
+ 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_required_R1(self):
+ registry = self.__registery()
+
+ got = list(registry.getRegisteredMatching(
+ required_interfaces = (R1, )
+ ))
+ got.sort()
+ expect = [
+ (None, P3, 'default P3'),
+ (Interface, P3, 'any P3'),
+ ]
+ expect.sort()
+ self.assertEqual(got, expect)
+
+ def test_getRegisteredMatching_required_multiple(self):
+ registry = self.__registery()
+
+ got = list(registry.getRegisteredMatching(
+ required_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_1(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_required_and_provided_1(self):
+ registry = self.__registery()
+
+ got = list(registry.getRegisteredMatching(
+ required_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_required_and_provided_2(self):
+ registry = self.__registery()
+
+ got = list(registry.getRegisteredMatching(
+ required_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)