[Zope-CVS] CVS: Packages/FunctionalTests/FunctionalTests/tests - test_Request.py:1.1.2.3

Karl Anderson cvs-admin at zope.org
Tue Nov 4 17:53:06 EST 2003


Update of /cvs-repository/Packages/FunctionalTests/FunctionalTests/tests
In directory cvs.zope.org:/tmp/cvs-serv1866

Modified Files:
      Tag: kra-misc-branch
	test_Request.py 
Log Message:
HTTPRequestTests: modified testHostPort(), added testAddGetField(), testContentType, testURIEncodedContentType(), testURIEncodedData(), testMethod(), testURIEncodedMethod()


=== Packages/FunctionalTests/FunctionalTests/tests/test_Request.py 1.1.2.2 => 1.1.2.3 ===
--- Packages/FunctionalTests/FunctionalTests/tests/test_Request.py:1.1.2.2	Mon Nov  3 19:16:18 2003
+++ Packages/FunctionalTests/FunctionalTests/tests/test_Request.py	Tue Nov  4 17:53:06 2003
@@ -171,14 +171,74 @@
 
         return self._getTargetClass()( name=name, URL=URL, *args, **kw )
 
-    def testPort(self):
-
+    def testHostPort(self):
+        """
+        Test that setting the host with or without the port in the URI
+        gives the right host and port.
+        """
         request = self._makeOne( URL='http://example.com' )
+        self.assertEquals( request.getHost(), 'example.com' )        
         self.assertEquals( request.getPort(), None )
         request = self._makeOne( URL='http://example.com:80' )
+        self.assertEquals( request.getHost(), 'example.com' )
         self.assertEquals( request.getPort(), 80 )
+
+    def testAddGetField(self):
+        "Test that adding, getting a field does the right thing."
+        expected = [ 'last_visit'
+                   , 'date'
+                   , '2001/11/12 17:21:03.25675 US/Eastern'
+                   ]        
+        request = self._makeOne( URL='http://example.com' )
+        request.addField(
+            'last_visit:date=2001/11/12 17:21:03.25675 US/Eastern')
+        got = request.getFields()
+        self.assertEquals( len( got ), 1 )
+        got = got[0]
+        self.assertEquals( len( expected ), len( got ) )
+        got = list( got )
+        while len( expected ):
+            self.assertEquals( got.pop(), expected.pop() )
+
+    # XXX I'm writing this based on what the methods do now, may be wrong
+    def testContentType(self):
+        "Test the base content type."
+        request = self._makeOne( URL='http://example.com' )
+        self.assertEquals( request.getContentType(),
+                           'application/x-www-form-urlencoded' )
+
+    # XXX I'm writing this based on what the methods do now, may be wrong
+    def testURIEncodedContentType(self):
+        "Test that adding a URI-encoded field sets the right content type."
+        request = self._makeOne( URL='http://example.com' )
+        request.addField(
+            'last_visit:date=2001/11/12 17:21:03.25675 US/Eastern' )
+        self.assertEquals( request.getContentType(),
+                          'application/x-www-form-urlencoded' )
+
+    # XXX I'm writing this based on what the methods do now, may be wrong
+    def testURIEncodedData(self):
+        "Test that adding a URI-encoded field sets the right data."
+        request = self._makeOne( URL='http://example.com' )
+        request.addField(
+            'last_visit:date=2001/11/12 17:21:03.25675 US/Eastern' )
+        data = 'last_visit:date=2001%2F11%2F12+17%3A21%3A03.25675+US%2FEastern'
+        self.assertEquals( request.getData(), data )
+
+    def testMethod(self):
+        "Test the base method."
+        request = self._makeOne( URL='http://example.com' )
+        self.assertEquals( request.getMethod(), 'GET' )
+
+    # XXX I'm writing this based on what the methods do now, may be wrong
+    def testURIEncodedMethod(self):
+        "Test that adding a URI-encoded sets the right method."
+        request = self._makeOne( URL='http://example.com' )
+        request.addField(
+            'last_visit:date=2001/11/12 17:21:03.25675 US/Eastern' )
+        self.assertEquals( request.getMethod(), 'POST' )        
         
-    # TODO:  test actual API
+    # TODO:  test more of the API
 
 class ZEORequestTests( unittest.TestCase
                      , _RequestBaseTests




More information about the Zope-CVS mailing list