00001
00002
00003
00004
00005
00006 import os, sys, unittest
00007 from ServiceTest import main, ServiceTestCase, ServiceTestSuite
00008 from ZSI import FaultException, ParsedSoap, SoapWriter
00009 """
00010 Unittest
00011
00012 WSDL: wsdl/vim.wsdl
00013 """
00014
00015
00016 def dispatch():
00017 """Run all dispatch tests"""
00018 suite = ServiceTestSuite()
00019 suite.addTest(unittest.makeSuite(VIMTestCase, 'test_dispatch'))
00020 return suite
00021
00022 def local():
00023 """Run all local tests"""
00024 suite = ServiceTestSuite()
00025 suite.addTest(unittest.makeSuite(VIMTestCase, 'test_local'))
00026 return suite
00027
00028 def net():
00029 """Run all network tests"""
00030 suite = ServiceTestSuite()
00031 suite.addTest(unittest.makeSuite(VIMTestCase, 'test_net'))
00032 return suite
00033
00034 def all():
00035 """Run all tests"""
00036 suite = ServiceTestSuite()
00037 suite.addTest(unittest.makeSuite(VIMTestCase, 'test_'))
00038 return suite
00039
00040
00041 class VIMTestCase(ServiceTestCase):
00042 name = "test_VIM"
00043 client_file_name = "VIM_client.py"
00044 types_file_name = "VIM_types.py"
00045 server_file_name = "VIM_server.py"
00046
00047 def __init__(self, methodName):
00048 ServiceTestCase.__init__(self, methodName)
00049 self.wsdl2py_args.append('--lazy')
00050 self.wsdl2py_args.append('-b')
00051
00052 def test_local_substitute_SessionManager(self):
00053
00054 MSG = """<?xml version="1.0" encoding="UTF-8"?>
00055 <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
00056 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
00057 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
00058 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
00059 <soapenv:Body>
00060 <RetrieveServiceContentResponse xmlns="urn:vim2">
00061 <returnval>
00062 <rootFolder type="Folder">group-d1</rootFolder>
00063 <propertyCollector type="PropertyCollector">propertyCollector</propertyCollector>
00064 <about>
00065 <name>VMware VirtualCenter</name>
00066 <fullName>VMware VirtualCenter 2.0.1 build-32042</fullName>
00067 <vendor>VMware, Inc.</vendor>
00068 <version>2.0.1</version>
00069 <build>32042</build>
00070 <localeVersion>INTL</localeVersion>
00071 <localeBuild>000</localeBuild>
00072 <osType>win32-x86</osType>
00073 <productLineId>vpx</productLineId>
00074 <apiType>VirtualCenter</apiType>
00075 <apiVersion>2.0.0</apiVersion>
00076 </about>
00077 <setting type="OptionManager">VpxSettings</setting>
00078 <userDirectory type="UserDirectory">UserDirectory</userDirectory>
00079 <sessionManager type="SessionManager">SessionManager</sessionManager>
00080 <authorizationManager type="AuthorizationManager">AuthorizationManager</authorizationManager>
00081 <perfManager type="PerformanceManager">PerfMgr</perfManager>
00082 <scheduledTaskManager type="ScheduledTaskManager">ScheduledTaskManager</scheduledTaskManager>
00083 <alarmManager type="AlarmManager">AlarmManager</alarmManager>
00084 <eventManager type="EventManager">EventManager</eventManager>
00085 <taskManager type="TaskManager">TaskManager</taskManager>
00086 <customizationSpecManager type="CustomizationSpecManager">CustomizationSpecManager</customizationSpecManager>
00087 <customFieldsManager type="CustomFieldsManager">CustomFieldsManager</customFieldsManager>
00088 <diagnosticManager type="DiagnosticManager">DiagMgr</diagnosticManager>
00089 <licenseManager type="LicenseManager">LicenseManager</licenseManager>
00090 <searchIndex type="SearchIndex">SearchIndex</searchIndex>
00091 </returnval>
00092 </RetrieveServiceContentResponse>
00093 </soapenv:Body>
00094 </soapenv:Envelope>"""
00095
00096
00097 ps = ParsedSoap(MSG)
00098 pyobj = ps.Parse( self.client_module.RetrieveServiceContentResponseMsg.typecode )
00099 sessionMgr = pyobj.Returnval.SessionManager
00100
00101
00102 msg = self.client_module.LogoutRequestMsg()
00103 msg._this = sessionMgr
00104 SoapWriter().serialize(msg)
00105
00106
00107
00108
00109 ps = ParsedSoap(MSG)
00110 pyobj = ps.Parse( self.client_module.RetrieveServiceContentResponseMsg.typecode )
00111
00112
00113 if __name__ == "__main__" :
00114 main()
00115