[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - testAPI.py:1.1.2.12
R. David Murray
rdmurray@bitdance.com
Wed, 27 Mar 2002 15:51:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv22970
Modified Files:
Tag: Zope-3x-branch
testAPI.py
Log Message:
Add unit test to make sure providing an adapter using more than one
factory works.
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testAPI.py 1.1.2.11 => 1.1.2.12 ===
class I1(Interface.Interface): pass
class I2(Interface.Interface): pass
+class I3(Interface.Interface): pass
class Comp:
__implements__ = I2
def __init__(self, context): self._context = context
def getContext(self): return self._context
+class Comp2:
+ __implements__ = I3
+ def __init__(self, context): self._context = context
+ def getContext(self): return self._context
comp = Comp(1)
@@ -36,6 +41,14 @@
c = getAdapter(ob, I2)
self.assertEquals(c.__class__, Comp)
self.assertEquals(c.getContext(), ob)
+
+ def testMultipleAdapterFactories(self):
+ from Zope.ComponentArchitecture import getAdapter, provideAdapter
+
+ provideAdapter(I1, I2, [Comp, Comp2])
+ c = getAdapter(ob, I2)
+ self.assertEquals(c.__class__, Comp2)
+ self.assertEquals(c.getContext().getContext(), ob)
def testAdapterForInterfaceNone(self):
from Zope.ComponentArchitecture import getAdapter, provideAdapter