• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

contrib/opal/ZSI/test/test_t5.py

00001 #!/usr/bin/env python
00002 import unittest, multifile, mimetools
00003 from ZSI import *
00004 from ZSI import resolvers
00005 from xml.dom import Node
00006 #from xml.dom.ext.reader import PyExpat
00007 from ZSI.parse import DefaultReader as Reader
00008 
00009 
00010 try:
00011     import cStringIO as StringIO
00012 except ImportError:
00013     import StringIO
00014 
00015 class t5TestCase(unittest.TestCase):
00016     "Test case wrapper for old ZSI t5 test case"
00017 
00018     def checkt5(self):
00019         istr = StringIO.StringIO(intext)
00020         m = mimetools.Message(istr)
00021         if  m.gettype()[0:10] == "multipart/":
00022             cid = resolvers.MIMEResolver(m['content-type'], istr)
00023             xml = cid.GetSOAPPart()
00024             print 'xml=', xml.getvalue()
00025             for h,b in cid.parts:
00026                 print h, b.read()
00027             dom = Reader.fromStream(xml)
00028             print dom
00029 
00030 def makeTestSuite():
00031     suite = unittest.TestSuite()
00032     suite.addTest(unittest.makeSuite(t5TestCase, "check"))
00033     return suite
00034 
00035 def main():
00036     unittest.main(defaultTest="makeTestSuite")
00037 
00038 intext = '''Content-Type: multipart/mixed; boundary="sep"
00039 Subject: testing
00040 
00041 skip this
00042 
00043 --sep
00044 Content-type: text/xml
00045 
00046 <foo xmlns='www.zolera.com'>hello world</foo>
00047 --sep
00048 Content-Type: text/plain
00049 content-id: <part111@example.zolera.com>
00050 
00051 this is some plain text
00052 --sep
00053 content-type: application/skipme
00054 
00055 do not see this
00056 okay?
00057 --sep
00058 Content-Type: text/xml
00059 Content-ID: <part2@example.zolera.com>
00060 
00061 <xml>spoken</xml>
00062 --sep--
00063 '''
00064 
00065 if __name__ == "__main__" : main()
00066 
00067 

Generated on Wed Oct 20 2010 11:12:16 for APBS by  doxygen 1.7.2