[Zope-CVS] CVS: Packages/WebService/tests - testSOAPMessage.py:1.2

Brian Lloyd brian@digicool.com
Mon, 17 Dec 2001 10:00:11 -0500


Update of /cvs-repository/Packages/WebService/tests
In directory cvs.zope.org:/tmp/cvs-serv23471/tests

Modified Files:
	testSOAPMessage.py 
Log Message:
Implemented MIME multipart encoding / decoding, refactored SOAPMessage 
interface to make it easier to customize.


=== Packages/WebService/tests/testSOAPMessage.py 1.1 => 1.2 ===
         self.assertEquals(params[1].value, 42)
 
+    def testMultipartMessage(self):
+        """Test building and reading a MIME multipart message."""
+        from WebService.SOAPMessage import SOAPMessage
+        from WebService.Utility import DOM
+
+        content_type = 'multipart/mixed; boundary="MIME_boundary"'
+
+        message = SOAPMessage(message_4)
+        message.setContentType(content_type)
+        message.deserialize()
+        
+        mimeparts = message.getMimeParts()
+        self.assertEquals(len(mimeparts), 3)
+
 
 
 
@@ -137,6 +151,65 @@
 </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>
 '''
+
+message_4='''This is a multi-part message in MIME format.
+--MIME_boundary
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+
+<SOAP-ENV:Envelope
+ xmlns="http://www.example.com/schemas/TEST"
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:ZSI="http://www.zolera.com/schemas/ZSI/">
+<SOAP-ENV:Body>
+<hreftest>
+    <stringtest href="cid:part1"/>
+    <b64 href="cid:partii"/>
+    <xmltest href="cid:12"/>
+</hreftest>
+</SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
+--MIME_boundary
+Content-Type: text/plain; charset=us-ascii; name="abs.txt"
+Content-Disposition: inline; filename="abs.txt"
+Content-Transfer-Encoding: 7bit
+Content-ID: part1
+
+Digitial Signatures in a Web Services World
+
+An influential Forrestor report created the term inverted security: it's
+not about who you keep out, it's about who you let in.	Customer portals,
+without a costly PKI deployment or application integration issues.
+
+--MIME_boundary
+Content-Type: application/pdf;
+ name="gmpharma.pdf"
+Content-Transfer-Encoding: base64
+Content-ID: partii
+Content-Disposition: inline;
+ filename="gmpharma.pdf"
+
+JVBERi0xLjINJeLjz9MNCjQzIDAgb2JqDTw8IA0vTGluZWFyaXplZCAxIA0vTyA0NSANL0gg
+WyAxMTQ0IDM5NiBdIA0vTCA2NjkwMiANL0UgMTAyODIgDS9OIDkgDS9UIDY1OTI0IA0+PiAN
+RB3nwVOQH9JpmFv6Ri2Zq7mlddSS2B5WcZwvAP+gy9QtuYlfqj1rsi9WqJOszzHXmXZ8fXxK
+XBBztIpgbkRrd+SGtY4QXo0fX0VN86uKXwtrkd7h1qiq2FUtXl6uNfnCoyX1Dve1O3RPRyhG
+sKn6fLMb+uSSIHPQkClRBwu5gechz/1PBUBSB34jXbPdMTIb+/wRP+pauSAhLBzFELDOgk5b
+PaIPAnIudFovQTc7Df2Ws9Atz4Bua+oINphIOojogG5LP3Tb3oNu8bsmuK+wFXEdbfgFIx+G
+gKULYx5A2WnaDXB5JeoRQg90S0HcX2dCPmRCqDXB/aX34KujsPwJ/UpRdxXPeAftDkQS6hag
+bh/yTOiUyqBz9CzxnyMYQGDO0jrUZ47kkWfmYvVg
+--MIME_boundary
+Content-ID: 12
+
+<foo xmlns="example.com" xmlns:Z="zolera">
+    this is a foo
+    <b xmlns:Z="zolera">redundnant ns decl</b>
+    <b Z:x="this was first" Z:a="2nd-orig">b test</b>
+</foo>
+
+--MIME_boundary--
+'''
+
 
 def test_suite():
     return unittest.makeSuite(SOAPMessageTests)