[Zope3-checkins] CVS: Zope3/src/zope/component/tests - test_api.py:1.13

michael dunstan michael at elyt.com
Mon Feb 9 02:41:51 EST 2004


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

Modified Files:
	test_api.py 
Log Message:
Add subscription adapters (partial adapters that return all possible factories
that match your query). 


=== Zope3/src/zope/component/tests/test_api.py 1.12 => 1.13 ===
--- Zope3/src/zope/component/tests/test_api.py:1.12	Wed Dec 17 05:07:00 2003
+++ Zope3/src/zope/component/tests/test_api.py	Mon Feb  9 02:41:21 2004
@@ -20,6 +20,7 @@
 from zope.component import getService
 from zope.component import getUtility, queryUtility
 from zope.component import getDefaultViewName
+from zope.component import queryMultiAdapter
 from zope.component.exceptions import ComponentLookupError
 from zope.component.servicenames import Adapters
 from zope.component.tests.placelesssetup import PlacelessSetup
@@ -163,6 +164,24 @@
         c = getAdapter(ob, I2)
         self.assertEquals(c.__class__, Comp)
         self.assertEquals(c.context.context, ob)
+
+    def testQueryMultiAdapter(self):
+        # Adapting a combination of 2 objects to an interface
+        class DoubleAdapter:
+            implements(I3)
+            def __init__(self, first, second):
+                self.first = first
+                self.second = second
+        class Ob2:
+            implements(I2)
+        ob2 = Ob2()
+        context = None
+        getService(context, Adapters).provideAdapter(I1, I3, [DoubleAdapter],
+                                                     with=[I2])
+        c = queryMultiAdapter((ob, ob2), I3, context=context)
+        self.assertEquals(c.__class__, DoubleAdapter)
+        self.assertEquals(c.first, ob)
+        self.assertEquals(c.second, ob2)
 
     def testAdapterForInterfaceNone(self):
 




More information about the Zope3-Checkins mailing list