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

Karl Anderson cvs-admin at zope.org
Fri Nov 7 14:14:13 EST 2003


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

Modified Files:
      Tag: kra-misc-branch
	test_Request.py 
Log Message:
HTTPRequestTests: added testURIEncodedMethod(), testMultipartContentTypeFile()
removed some XXX comments after looking stuff up :)


=== Packages/FunctionalTests/FunctionalTests/tests/test_Request.py 1.1.2.3 => 1.1.2.4 ===
--- Packages/FunctionalTests/FunctionalTests/tests/test_Request.py:1.1.2.3	Tue Nov  4 17:53:06 2003
+++ Packages/FunctionalTests/FunctionalTests/tests/test_Request.py	Fri Nov  7 14:14:12 2003
@@ -207,7 +207,6 @@
         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' )
@@ -216,7 +215,6 @@
         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' )
@@ -230,13 +228,48 @@
         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' )        
+
+#     def testMultipartContentTypeForm(self):
+#         """
+#         Test the content type of a multipart/form-data request
+#         after adding a form field.
+#         """
+#         request = self._makeOne( URL='http://example.com' )
+#         request.addField( 'last_visit:form=foobar' )
+#         self.assertEquals( request.getContentType()
+#                          , 'multipart/form-data' )
+
+    def testMultipartContentTypeFile(self):
+        """
+        Test the content type of a multipart/form-data request
+        after adding a file field.
+        """
+        request = self._makeOne( URL='http://example.com' )
+        request.addField( 'last_visit:file=foobar' )
+        self.assertEquals( request.getContentType(),
+                           'multipart/form-data' )
+
+#     def testMultipartDataForm(self):
+#         "Test the data returned by a multipart/form-data request."
+#         expected = 'multipart/form-data;\n boundary="64.242.113.150.1056.29208.1068160273.155.31644"\n--64.242.113.150.1056.29208.1068160273.155.31644\nContent-Type: text/plain\ncontent-disposition: form-data; name="last_visit"\n\nfoobar\n--64.242.113.150.1056.29208.1068160273.155.31644\nContent-Type: text/plain\ncontent-disposition: form-data; name="next_visit"\n\nbazqux\n--64.242.113.150.1056.29208.1068160273.155.31644--\n'
+#         request = self._makeOne( URL='http://example.com' )
+#         request.addField( 'last_visit:form=foobar' )
+#         request.addField( 'next_visit:form=bazqux' )
+#         got = request.getData()
+#         # the boundaries are generated and may change
+#         bdReg = 'boundary="([^\n]*)"\n'
+#         import re
+#         expectedBd = re.search( bdReg, expected ).groups()[0]
+#         expected = expected.replace(expectedBd, '[boundary]')
+#         gotBd = re.search( bdReg, got ).groups()[0]
+#         got = got.replace(gotBd, '[boundary]')
+#         self.assertEquals(expected, got)
         
     # TODO:  test more of the API
 




More information about the Zope-CVS mailing list