[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/XMLRPC/tests - TestViews.py:1.1.4.2.14.1 testDirectives.py:1.1.4.3.8.1 testXMLRPCRequest.py:1.1.2.2.14.1
Jim Fulton
jim@zope.com
Wed, 29 May 2002 11:10:25 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/XMLRPC/tests
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/Publisher/XMLRPC/tests
Modified Files:
Tag: Zope3InWonderland-branch
TestViews.py testDirectives.py testXMLRPCRequest.py
Log Message:
- Added permission_id attribute to adapter and utility directives.
- Got rid of old getView, getResource, and getDefaultViewName.
Renamed getRequestView to getView (and so on).
Changed view interface to use context, rather than getContext.
Introduced notion of presentation types (e.g. IBrowserPresentation,
which is cleaner than IBrowserPublisher).
- Began converting to get/queryFoo, which is much nicer.
- Many formatting fixups.
=== Zope3/lib/python/Zope/Publisher/XMLRPC/tests/TestViews.py 1.1.4.2 => 1.1.4.2.14.1 ===
__implements__ = IXMLRPCPublisher
- def __init__(self,context):
- self._context = context
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
class VZMI(V1):
pass
class R1:
+ def __init__(self, request):
+ self.request = request
+
__implements__ = IXMLRPCPublisher
-r1 = R1()
-
class RZMI(R1):
pass
-
-rZMI = RZMI()
=== Zope3/lib/python/Zope/Publisher/XMLRPC/tests/testDirectives.py 1.1.4.3 => 1.1.4.3.8.1 ===
#
##############################################################################
-import unittest
-from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.Publisher.XMLRPC.IXMLRPCPublisher import IXMLRPCPublisher
-from Zope.Publisher.XMLRPC.tests.TestViews import IC, V1, VZMI, R1, RZMI
-from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
-from Zope.ComponentArchitecture import getView
-from cStringIO import StringIO
-
-template = """<zopeConfigure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:xmlrpc='http://namespaces.zope.org/xmlrpc'>
- %s
- </zopeConfigure>"""
-
-class Ob:
- __implements__ = IC
-
-class Test(PlacelessSetup, unittest.TestCase):
-
- def testView(self):
-
- ob = Ob()
- self.assertEqual(getView(ob, 'test', IXMLRPCPublisher, None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <directive name="view"
- attributes="component, name, for, layer"
- handler="Zope.Publisher.XMLRPC.metaConfigure.view"
- namespace="http://namespaces.zope.org/xmlrpc" />
- <xmlrpc:view name="test"
- factory="Zope.Publisher.XMLRPC.tests.TestViews.V1"
- for="Zope.Publisher.XMLRPC.tests.TestViews.IC" />
- '''
- )))
-
- self.assertEqual(getView(ob, 'test', IXMLRPCPublisher, None
- ).__class__, V1)
-
-
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__ == '__main__':
- unittest.TextTestRunner().run(test_suite())
+import unittest
+from Zope.Configuration.xmlconfig import xmlconfig
+from Zope.Publisher.XMLRPC.IXMLRPCPublisher import IXMLRPCPublisher
+from Zope.Publisher.XMLRPC.tests.TestViews import IC, V1, VZMI, R1, RZMI
+from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
+from Zope.ComponentArchitecture import queryView
+from cStringIO import StringIO
+
+from Zope.ComponentArchitecture.tests.Request import Request
+
+template = """<zopeConfigure
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:xmlrpc='http://namespaces.zope.org/xmlrpc'>
+ %s
+ </zopeConfigure>"""
+
+class Ob:
+ __implements__ = IC
+
+class Test(PlacelessSetup, unittest.TestCase):
+
+ def testView(self):
+
+ ob = Ob()
+ self.assertEqual(queryView(ob, 'test', Request(IXMLRPCPublisher), None), None)
+
+ xmlconfig(StringIO(template % (
+ '''
+ <directive name="view"
+ attributes="component, name, for, layer"
+ handler="Zope.Publisher.XMLRPC.metaConfigure.view"
+ namespace="http://namespaces.zope.org/xmlrpc" />
+ <xmlrpc:view name="test"
+ factory="Zope.Publisher.XMLRPC.tests.TestViews.V1"
+ for="Zope.Publisher.XMLRPC.tests.TestViews.IC" />
+ '''
+ )))
+
+ self.assertEqual(queryView(ob, 'test', Request(IXMLRPCPublisher), None
+ ).__class__, V1)
+
+
+
+def test_suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
+
+if __name__ == '__main__':
+ unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/Publisher/XMLRPC/tests/testXMLRPCRequest.py 1.1.2.2 => 1.1.2.2.14.1 ===
- def testIViewRequest(self):
+ def testIPresentationRequest(self):
''' test the IView request'''
r = self._createRequest()
- self.failUnless( r.getViewType() is IXMLRPCPublisher)
+ self.failUnless( r.getPresentationType() is IXMLRPCPublisher)
def testProcessInput(self):