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

contrib/opal/ZSI/test/wsdl2py/test_DateService.py

00001 #!/usr/bin/env python
00002 ############################################################################
00003 # Joshua R. Boverhof, LBNL
00004 # See LBNLCopyright for copyright notice!
00005 # Tests for Holger's DateService
00006 ###########################################################################
00007 import sys, unittest, time
00008 from ServiceTest import main, ServiceTestCase, ServiceTestSuite, TestException
00009 
00010 """
00011 Unittest for contacting the DateService rpc/literal tests.
00012 
00013 From the paper "Interoperable WSDL/SOAP web services introduction: 
00014 Python ZSI, Excel XP, gSOAP C/C++ & Applix SS", Holger Joukl
00015 
00016 WSDL: DateService.wsdl
00017 
00018 """
00019 # General targets
00020 def dispatch():
00021     """Run all dispatch tests"""
00022     suite = ServiceTestSuite()
00023     suite.addTest(unittest.makeSuite(Test, 'test_dispatch'))
00024     return suite
00025 
00026 def local():
00027     """Run all local tests"""
00028     suite = ServiceTestSuite()
00029     suite.addTest(unittest.makeSuite(Test, 'test_local'))
00030     return suite
00031 
00032 def net():
00033     """Run all network tests"""
00034     suite = ServiceTestSuite()
00035     suite.addTest(unittest.makeSuite(Test, 'test_net'))
00036     return suite
00037     
00038 def all():
00039     """Run all tests"""
00040     suite = ServiceTestSuite()
00041     suite.addTest(unittest.makeSuite(Test, 'test_'))
00042     return suite
00043 
00044 
00045 class Test(ServiceTestCase):
00046     """Test case for Holger's DateService
00047     """
00048     name = "test_DateService"
00049     client_file_name = "DateService_client.py"
00050     types_file_name = "DateService_types.py"
00051     server_file_name = "DateService_server.py"
00052 
00053     def __init__(self, methodName):
00054         ServiceTestCase.__init__(self, methodName)
00055         self.wsdl2py_args.append('-b')
00056     
00057     #def test_local_getDate(self):
00058     #    from ZSI.writer import SoapWriter
00059         
00060     def test_dispatch_getCurrentDate_getDate(self):
00061         offset = 9
00062         loc = self.client_module.simple_Date_ServiceLocator()
00063         port = loc.getDateService_Port(**self.getPortKWArgs())
00064         print "START"
00065         msg = self.client_module.getCurrentDateRequest()
00066         msg.Input = "Test"
00067         rsp = port.getCurrentDate(msg)
00068         
00069         today = rsp.Today
00070         today.Month
00071         today.Day
00072         today.Hour
00073         today.Minute
00074         today.Second
00075         today.Weekday
00076         today.DayOfYear
00077         today.Dst
00078 
00079         dateRequest = self.client_module.getDateRequest()
00080         # We use the current date as input to getDate
00081         dateRequest.Someday = today
00082         dateRequest.Offset = offset
00083         date = port.getDate(dateRequest)
00084 
00085         print '\n\nRESULT'
00086         print '%10s = %s' % ('today', _make_asctime(today))
00087         print '%6s + %d = %s' % ('today', dateRequest.Offset, _make_asctime(date.Day))
00088 
00089 
00090 def _make_asctime(date_object):
00091     timeTuple = (date_object._year, date_object._month, date_object._day,
00092                  date_object._hour, date_object._minute, date_object._second,
00093                  date_object._weekday, date_object._dayOfYear, date_object._dst
00094                  )
00095     return time.asctime(timeTuple)
00096 
00097         
00098 
00099 if __name__ == "__main__" :
00100     main()

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