[Zope3-checkins] CVS: Zope3/src/zope/publisher/tests - test_http.py:1.29

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Mar 20 11:27:21 EST 2004


Update of /cvs-repository/Zope3/src/zope/publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv11370/src/zope/publisher/tests

Modified Files:
	test_http.py 
Log Message:


Added test for response.redirect.


=== Zope3/src/zope/publisher/tests/test_http.py 1.28 => 1.29 ===
--- Zope3/src/zope/publisher/tests/test_http.py:1.28	Fri Mar 19 15:26:44 2004
+++ Zope3/src/zope/publisher/tests/test_http.py	Sat Mar 20 11:27:21 2004
@@ -107,6 +107,28 @@
             "\r\n"
             "'5', 6")
 
+    def testRedirect(self):
+        # test HTTP/1.0
+        env = {'SERVER_PROTOCOL':'HTTP/1.0'}
+
+        request = self._createRequest(env, '')
+        location = request.response.redirect('http://foobar.com/redirected')
+        self.assertEquals(location, 'http://foobar.com/redirected')
+        self.assertEquals(request.response.getStatus(), 302)
+        self.assertEquals(request.response._headers['location'], location)
+        
+        # test HTTP/1.1
+        env = {'SERVER_PROTOCOL':'HTTP/1.1'}
+
+        request = self._createRequest(env, '')
+        location = request.response.redirect('http://foobar.com/redirected')
+        self.assertEquals(request.response.getStatus(), 303)
+
+        # test explicit status
+        request = self._createRequest(env, '')
+        request.response.redirect('http://foobar.com/explicit', 304)
+        self.assertEquals(request.response.getStatus(), 304)
+        
     def testRequestEnvironment(self):
         req = self._createRequest()
         publish(req, handle_errors=0) # Force expansion of URL variables




More information about the Zope3-Checkins mailing list