[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/tests - BaseTestIApplicationRequest.py:1.1.2.2 testPublisher.py:1.1.2.7.2.2
Jim Fulton
jim@zope.com
Mon, 25 Mar 2002 18:30:43 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv31034/Zope/Publisher/tests
Modified Files:
Tag: Zope3-publisher-refactor-branch
BaseTestIApplicationRequest.py testPublisher.py
Log Message:
Refactord BaseRequest/BaseResponse and HTTPRequest/Response some more:
- Use slots so I can keep track of what's going on. ;)
- Use properties for environment, cookies, headers, URLs.
- Put URL responsibilities in HTTPRequest.
- Have HTTP traverse delegate to and augment Base traverse.
=== Zope3/lib/python/Zope/Publisher/tests/BaseTestIApplicationRequest.py 1.1.2.1 => 1.1.2.2 ===
from Interface.Common.tests.BaseTestMapping import BaseTestIEnumerableMapping
+from Interface.Common.tests.BaseTestMapping \
+ import testIEnumerableMapping, testIReadMapping
+
class BaseTestIApplicationRequest(BaseTestIEnumerableMapping):
@@ -32,3 +35,18 @@
def testHaveCustomTestsForIApplicationRequest(self):
"Make sure that tests are defined for things we can't test here"
self.test_IApplicationRequest_body
+
+ def testEnvironment(self):
+
+ request = self._Test__new(foo='Foo', bar='Bar')
+
+ try: request.environment = {}
+ except AttributeError: pass
+ else: raise "Shouldn't be able to set environment"
+
+ environment = request.environment
+
+ testIReadMapping(self, environment,
+ {'foo': 'Foo', 'bar': 'Bar'},
+ ['splat'])
+
=== Zope3/lib/python/Zope/Publisher/tests/testPublisher.py 1.1.2.7.2.1 => 1.1.2.7.2.2 ===
self.app.noDocString = NoDocstringItem()
- def _createRequest(self, path):
+ def _createRequest(self, path, outstream=None, **kw):
+ if outstream is None:
+ outstream = StringIO()
publication = TestPublication(self.app)
path = path.split('/')
path.reverse()
- request = BaseRequest(StringIO(''), StringIO(), {})
+ request = BaseRequest(StringIO(''), outstream, kw)
request.setTraversalStack(path)
request.setPublication(publication)
return request
- def _publisherResults(self, path):
- request = self._createRequest(path)
+ def _publisherResults(self, path, **kw):
+ outstream = StringIO()
+ request = self._createRequest(path, outstream=outstream, **kw)
publish(request)
- return request.getResponse().outstream.getvalue()
+ return outstream.getvalue()
def testImplementsIPublication(self):
self.failUnless(IPublication.isImplementedBy(