[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - testSkins.py:1.1.2.2
Andreas Jung
andreas@digicool.com
Thu, 10 Jan 2002 11:03:34 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv32566/tests
Modified Files:
Tag: Zope-3x-branch
testSkins.py
Log Message:
added getRequestView()
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testSkins.py 1.1.2.1 => 1.1.2.2 ===
from Zope.ComponentArchitecture import defineSkin, provideView, getView, _clear
+from Zope.ComponentArchitecture import getRequestView
from Interface import Interface
class Test(unittest.TestCase):
@@ -44,6 +45,54 @@
self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C2)
provideView(I1, 'test', I2, C3, layer='foo')
self.assertEqual(getView(O(), 'test', I2, skin='foo').__class__, C3)
+
+
+
+ def testGetRequestViewMethod(self):
+
+ class I1(Interface): pass
+ class I2(Interface): pass
+
+ class C1:
+ __implements__ = I2
+ __used_for__ = I1
+ def __init__(self, o): self._context=o
+ class C2(C1): pass
+ class C3(C1): pass
+
+ class O: __implements__ = I1
+
+ class Request:
+
+ def __init__(self,iface, skin):
+ self._iface = iface
+ self._skin = skin
+
+ # Implementation methods for interface
+ # Zope.ComponentArchitecture.IViewService.IViewRequest
+
+ def getViewSkin(self):
+ '''See interface IViewRequest'''
+
+ return self._skin
+
+ def getViewType(self):
+ '''See interface IViewRequest'''
+
+ return self._iface
+
+
+ provideView(I1, 'test', I2, C1)
+ self.assertEqual(getRequestView(O(), 'test', Request(I2,'') ).__class__, C1)
+ defineSkin('foo', ('foo', ''))
+ self.assertEqual(getRequestView(O(), 'test', Request(I2, 'foo')).__class__, C1)
+ provideView(None, 'test', I2, C2)
+ self.assertEqual(getRequestView(O(), 'test', Request(I2, 'foo')).__class__, C1)
+ provideView(None, 'test', I2, C2, layer='foo')
+ self.assertEqual(getRequestView(O(), 'test', Request(I2, 'foo')).__class__, C2)
+ provideView(I1, 'test', I2, C3, layer='foo')
+ self.assertEqual(getRequestView(O(), 'test', Request(I2, 'foo')).__class__, C3)
+
def test_suite():