[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - test_wrapper_hooks.py:1.1.2.3

Steve Alexander steve@cat-box.net
Wed, 14 May 2003 10:14:17 -0400


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

Modified Files:
      Tag: stevea-decorators-branch
	test_wrapper_hooks.py 
Log Message:
Implemented interface combining for the decorator.


=== Zope3/src/zope/app/component/tests/test_wrapper_hooks.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/component/tests/test_wrapper_hooks.py:1.1.2.2	Wed May 14 09:54:12 2003
+++ Zope3/src/zope/app/component/tests/test_wrapper_hooks.py	Wed May 14 10:14:16 2003
@@ -19,7 +19,8 @@
 import unittest
 
 from zope.app.interfaces.component import IDecoratorSpec
-from zope.interface import implements
+from zope.interface import Interface, implements, InterfaceSpecification
+from zope.interface import directlyProvides
 from zope.security.proxy import Proxy, getObject, getChecker
 from zope.proxy.context.wrapper import getobject, getcontext, getdict
 from zope.proxy.context.decorator import Decorator
@@ -57,6 +58,17 @@
         self.inner = inner
         self.outer = outer
 
+class IFoo(Interface):
+    pass
+
+class Foo:
+    implements(IFoo)
+
+class IBar(Interface):
+    pass
+
+class IBaz(Interface):
+    pass
 
 class TestDecorate(TestMixinDecoratedChecker, unittest.TestCase):
 
@@ -73,7 +85,7 @@
 
         mt = True
         mf = Mixin
-        mis = ()
+        mis = None
         n = ('x', 'y')
         spec = DecoratorSpecStub(mt, mf, mis, n, {}, {})
         ob = SomeObject()
@@ -117,7 +129,7 @@
 
         mt = True
         mf = Mixin
-        mis = ()
+        mis = None
         n = ('x', 'y')
         spec = DecoratorSpecStub(mt, mf, mis, n, {}, {})
 
@@ -157,7 +169,33 @@
         self.assert_(getObject(d).__Security_checker__ is getChecker(d))
 
     def test_decorateInterfaceSpec(self):
-        pass
+        from zope.app.component.hooks import decorate
+
+        ob = Foo()
+        parent = object()
+        kw = {}
+
+        mt = True
+        mf = Mixin
+        mis = None
+        n = ('x', 'y')
+        spec = DecoratorSpecStub(mt, mf, mis, n, {}, {})
+
+        self.assert_(IFoo.isImplementedBy(ob))
+        d = decorate(spec, ob, parent, kw)
+        self.assert_(IFoo.isImplementedBy(d))
+        self.failIf(IBar.isImplementedBy(d))
+
+        spec.mixinInterfaceSpec = InterfaceSpecification(IBar)
+        d = decorate(spec, ob, parent, kw)
+        self.assert_(IFoo.isImplementedBy(d))
+        self.assert_(IBar.isImplementedBy(d))
+
+        directlyProvides(ob, IBaz)
+        d = decorate(spec, ob, parent, kw)
+        self.assert_(IFoo.isImplementedBy(d))
+        self.assert_(IBar.isImplementedBy(d))
+        self.assert_(IBaz.isImplementedBy(d))
 
 
 def test_suite():