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

Karl Anderson cvs-admin at zope.org
Fri Nov 14 17:29:03 EST 2003


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

Modified Files:
      Tag: kra-misc-branch
	test_Request.py 
Log Message:
added HTTPRequestTests:testMultipartContentTypeForm(), testMultipartDataForm()


=== Packages/FunctionalTests/FunctionalTests/tests/test_Request.py 1.1.2.5 => 1.1.2.6 ===
--- Packages/FunctionalTests/FunctionalTests/tests/test_Request.py:1.1.2.5	Wed Nov 12 14:51:47 2003
+++ Packages/FunctionalTests/FunctionalTests/tests/test_Request.py	Fri Nov 14 17:29:02 2003
@@ -241,15 +241,16 @@
             '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 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=foobar' )
+        request.setMultipart()
+        self.assertEquals( request.getContentType()
+                         , 'multipart/form-data' )
 
     def testMultipartContentTypeFile(self):
         """
@@ -261,21 +262,22 @@
         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)
+    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=foobar' )
+        request.addField( 'next_visit=bazqux' )
+        request.setMultipart()
+        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