[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/testing/ - re-enable HTTPCaller.chooseRequestClass as a thin wrapper around

Benji York benji at zope.com
Tue Aug 16 11:22:41 EDT 2005


Log message for revision 37963:
  - re-enable HTTPCaller.chooseRequestClass as a thin wrapper around 
  zope.app.publication.httpfactory.chooseClasses
  - add tests to ensure it doesn't disappear again in the future
  

Changed:
  U   Zope3/trunk/src/zope/app/testing/functional.py
  U   Zope3/trunk/src/zope/app/testing/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/testing/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/functional.py	2005-08-16 15:00:00 UTC (rev 37962)
+++ Zope3/trunk/src/zope/app/testing/functional.py	2005-08-16 15:22:41 UTC (rev 37963)
@@ -577,8 +577,8 @@
         old_site = getSite()
         setSite(None)
 
-        request_cls, publication_cls = chooseClasses(method, environment)
-
+        request_cls, publication_cls = self.chooseRequestClass(method, path,
+                                                               environment)
         app = FunctionalTestSetup().getApplication()
 
         request = app._request(
@@ -609,6 +609,11 @@
 
         return response
 
+    def chooseRequestClass(self, method, path, environment):
+        """Choose and return a request class and a publication class"""
+        # note that `path` is unused by the default implementation (BBB)
+        return chooseClasses(method, environment)
+ 
 
 def FunctionalDocFileSuite(*paths, **kw):
     globs = kw.setdefault('globs', {})

Modified: Zope3/trunk/src/zope/app/testing/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/tests.py	2005-08-16 15:00:00 UTC (rev 37962)
+++ Zope3/trunk/src/zope/app/testing/tests.py	2005-08-16 15:22:41 UTC (rev 37963)
@@ -193,11 +193,25 @@
         self.assertEquals(auth_header(header), expected)
 
 
+class HTTPCallerTestCase(unittest.TestCase):
+
+    def test_chooseRequestClass(self):
+        from zope.publisher.interfaces import IRequest, IPublication
+
+        caller = functional.HTTPCaller()
+        request_class, publication_class = caller.chooseRequestClass(
+            method='GET', path='/', environment={})
+
+        self.assert_(IRequest.implementedBy(request_class))
+        self.assert_(IPublication.implementedBy(publication_class))
+
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(FunctionalHTTPDocTest),
         unittest.makeSuite(DocResponseWrapperTestCase),
-        unittest.makeSuite(AuthHeaderTestCase)
+        unittest.makeSuite(AuthHeaderTestCase),
+        unittest.makeSuite(HTTPCallerTestCase),
         ))
 
 if __name__ == '__main__':



More information about the Zope3-Checkins mailing list