[Zope3-checkins] CVS: Zope3/src/zope/publisher/tests -
test_browserrequest.py:1.11 test_http.py:1.28
test_xmlrpcrequest.py:1.9
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Mar 19 15:26:45 EST 2004
Update of /cvs-repository/Zope3/src/zope/publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv11983/src/zope/publisher/tests
Modified Files:
test_browserrequest.py test_http.py test_xmlrpcrequest.py
Log Message:
Clean up the publisher to not depend on zope.app and zope.component
anymore. All the view and resource code and interfaces have moved to
zope.app.publisher.
=== Zope3/src/zope/publisher/tests/test_browserrequest.py 1.10 => 1.11 ===
--- Zope3/src/zope/publisher/tests/test_browserrequest.py:1.10 Mon Jan 12 03:02:02 2004
+++ Zope3/src/zope/publisher/tests/test_browserrequest.py Fri Mar 19 15:26:44 2004
@@ -11,14 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-import unittest
-
-from zope.component.tests.placelesssetup import PlacelessSetup
-from zope.app.tests import ztapi
+"""Browser Request Tests
-from zope.i18n.interfaces import IUserPreferredCharsets
+$Id$
+"""
+import unittest
-from zope.publisher.http import IHTTPRequest
from zope.publisher.http import HTTPCharsets
from zope.publisher.browser import BrowserRequest
from zope.publisher.interfaces import NotFound
@@ -43,9 +41,16 @@
return ob.browserDefault(request)
return ob, ()
+class TestBrowserRequest(BrowserRequest, HTTPCharsets):
+ """Make sure that our request also implements IHTTPCharsets, so that we do
+ not need to register any adapters."""
+
+ def __init__(self, *args, **kw):
+ self.request = self
+ BrowserRequest.__init__(self, *args, **kw)
-class BrowserTests(HTTPTests, PlacelessSetup):
+class BrowserTests(HTTPTests):
_testEnv = {
'PATH_INFO': '/folder/item',
@@ -61,8 +66,6 @@
def setUp(self):
super(BrowserTests, self).setUp()
- ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets,
- HTTPCharsets)
class AppRoot:
" "
@@ -113,7 +116,7 @@
if outstream is None:
outstream = StringIO()
instream = StringIO(body)
- request = BrowserRequest(instream, outstream, env)
+ request = TestBrowserRequest(instream, outstream, env)
request.setPublication(publication)
return request
=== Zope3/src/zope/publisher/tests/test_http.py 1.27 => 1.28 ===
--- Zope3/src/zope/publisher/tests/test_http.py:1.27 Thu Mar 18 15:03:56 2004
+++ Zope3/src/zope/publisher/tests/test_http.py Fri Mar 19 15:26:44 2004
@@ -18,13 +18,6 @@
"""
import unittest
-# XXX evil zope.app imports :(
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.security.interfaces import IPrincipal
-
-# XX, Hm, zope.component dependency is suspect
-import zope.component
-
from zope.interface import implements
from zope.publisher.interfaces.logginginfo import ILoggingInfo
from zope.publisher.http import HTTPRequest
@@ -40,23 +33,19 @@
class UserStub:
- implements(IPrincipal)
+ implements(ILoggingInfo)
+
def __init__(self, id):
self._id = id
+
def getId(self):
return self._id
-class PrincipalLoggingStub:
- implements(ILoggingInfo)
-
- def __init__(self, object):
- self.object = object
-
def getLogMessage(self):
- return self.object.getId()
+ return self._id
-class HTTPTests(PlacefulSetup, unittest.TestCase):
+class HTTPTests(unittest.TestCase):
_testEnv = {
'PATH_INFO': '/folder/item',
@@ -72,7 +61,6 @@
}
def setUp(self):
- PlacefulSetup.setUp(self)
class AppRoot:
" "
@@ -213,7 +201,8 @@
self.assertEquals(req.getHeader('TEST_HEADER', literal=True), u'test')
self.assertEquals(req.getHeader('TEST-HEADER', literal=True), None)
self.assertEquals(req.getHeader('test_header', literal=True), None)
- self.assertEquals(req.getHeader('Another-Test', literal=True), 'another')
+ self.assertEquals(req.getHeader('Another-Test', literal=True),
+ 'another')
def testBasicAuth(self):
from zope.publisher.interfaces.http import IHTTPCredentials
@@ -236,8 +225,6 @@
def setAuthUserName(self, name):
self.auth_user_name = name
- as = zope.component.getService(None, 'Adapters')
- as.register([IPrincipal], ILoggingInfo, '', PrincipalLoggingStub)
task = HTTPTaskStub()
req = self._createRequest(outstream=task)
req.setUser(UserStub("jim"))
=== Zope3/src/zope/publisher/tests/test_xmlrpcrequest.py 1.8 => 1.9 ===
--- Zope3/src/zope/publisher/tests/test_xmlrpcrequest.py:1.8 Mon Mar 15 15:42:13 2004
+++ Zope3/src/zope/publisher/tests/test_xmlrpcrequest.py Fri Mar 19 15:26:44 2004
@@ -11,22 +11,17 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-import unittest
-
-from zope.component.tests.placelesssetup import PlacelessSetup
-import zope.component
+"""XML-RPC Request Tests
-from zope.i18n.interfaces import IUserPreferredCharsets
+$Id$
+"""
+import unittest
+from StringIO import StringIO
-from zope.publisher.http import IHTTPRequest
+from zope.publisher.base import DefaultPublication
from zope.publisher.http import HTTPCharsets
-
from zope.publisher.xmlrpc import XMLRPCRequest
-from zope.publisher.base import DefaultPublication
-
-from cStringIO import StringIO
-
class Publication(DefaultPublication):
require_docstrings = 0
@@ -37,7 +32,16 @@
return ob, ()
-xmlrpc_call = '''<?xml version='1.0'?>
+class TestXMLRPCRequest(XMLRPCRequest, HTTPCharsets):
+ """Make sure that our request also implements IHTTPCharsets, so that we do
+ not need to register any adapters."""
+
+ def __init__(self, *args, **kw):
+ self.request = self
+ XMLRPCRequest.__init__(self, *args, **kw)
+
+
+xmlrpc_call = u'''<?xml version='1.0'?>
<methodCall>
<methodName>action</methodName>
<params>
@@ -49,7 +53,7 @@
'''
-class XMLRPCTests(PlacelessSetup, unittest.TestCase):
+class XMLRPCTests(unittest.TestCase):
"""The only thing different to HTTP is the input processing; so there
is no need to redo all the HTTP tests again.
"""
@@ -70,9 +74,6 @@
def setUp(self):
super(XMLRPCTests, self).setUp()
- as = zope.component.getService(None, 'Adapters')
- as.register([IHTTPRequest], IUserPreferredCharsets, '', HTTPCharsets)
-
class AppRoot:
" "
@@ -113,7 +114,7 @@
if outstream is None:
outstream = StringIO()
instream = StringIO(body)
- request = XMLRPCRequest(instream, outstream, env)
+ request = TestXMLRPCRequest(instream, outstream, env)
request.setPublication(publication)
return request
More information about the Zope3-Checkins
mailing list