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

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


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

Modified Files:
      Tag: kra-misc-branch
	test_Request.py 
Log Message:
HTTPRequestTests:
testMultipartContentTypeForm(): updated
testMultipartDataForm(): updated
testMultpartContentTypeFile(): commented out, not implemented


=== Packages/FunctionalTests/FunctionalTests/tests/test_Request.py 1.1.2.6 => 1.1.2.7 ===
--- Packages/FunctionalTests/FunctionalTests/tests/test_Request.py:1.1.2.6	Fri Nov 14 17:29:02 2003
+++ Packages/FunctionalTests/FunctionalTests/tests/test_Request.py	Fri Nov 14 19:55:29 2003
@@ -249,36 +249,42 @@
         request = self._makeOne( URL='http://example.com' )
         request.addField( 'last_visit=foobar' )
         request.setMultipart()
-        self.assertEquals( request.getContentType()
-                         , 'multipart/form-data' )
+        self.assertEquals( request.getContentType()[:30]
+                         , 'multipart/form-data; boundary=' )
 
-    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 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()[:30]
+   #                      , 'multipart/form-data; boundary=' )
 
     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'
+        """
+        Test that the data returned by a multipart/form-data request is proper,
+        and that the boundary matches that given by the content type.
+        """
+        expected = '--[boundary]\nContent-Type: text/plain\ncontent-disposition: form-data; name="last_visit"\n\nfoobar\n--[boundary]\nContent-Type: text/plain\ncontent-disposition: form-data; name="next_visit"\n\nbazqux\n--[boundary]--\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'
+        type = request.getContentType()
         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]')
+        boundary = re.search('boundary="([^"]*)"', type).groups()[0]
+        # the boundaries are generated and may change
+        #bdReg = 'boundary="([^\n]*)"\n'
+        #expectedBd = re.search( bdReg, expected ).groups()[0]
+        #expected = expected.replace(expectedBd, '[boundary]')
+        #gotBd = re.search( bdReg, got ).groups()[0]
+        #got = got.replace(gotBd, '[boundary]')
+        got = got.replace(boundary, '[boundary]')
         self.assertEquals(expected, got)
-        
+
     # TODO:  test more of the API
 
 class ZEORequestTests( unittest.TestCase




More information about the Zope-CVS mailing list