00001
00002
00003
00004
00005
00006 import sys, unittest
00007 from ServiceTest import main, ServiceTestCase, ServiceTestSuite
00008 import ZSI
00009 from ZSI import FaultException
00010 """
00011 Unittest for contacting the OPC XML-DA Service.
00012
00013 WSDL: http://tswinc.us/XMLDADemo/ts_sim/OpcDaGateway.asmx?WSDL
00014 """
00015
00016
00017 def dispatch():
00018 """Run all dispatch tests"""
00019 suite = ServiceTestSuite()
00020 suite.addTest(unittest.makeSuite(OPCServiceTest, 'test_dispatch'))
00021 return suite
00022
00023 def local():
00024 """Run all local tests"""
00025 suite = ServiceTestSuite()
00026 suite.addTest(unittest.makeSuite(OPCServiceTest, 'test_local'))
00027 return suite
00028
00029 def net():
00030 """Run all network tests"""
00031 suite = ServiceTestSuite()
00032 suite.addTest(unittest.makeSuite(OPCServiceTest, 'test_net'))
00033 return suite
00034
00035 def all():
00036 """Run all tests"""
00037 suite = ServiceTestSuite()
00038 suite.addTest(unittest.makeSuite(OPCServiceTest, 'test_'))
00039 return suite
00040
00041
00042 class OPCServiceTest(ServiceTestCase):
00043 """Test case for OPCService Web service
00044
00045 def GetProperties(self, request):
00046 def Subscribe(self, request):
00047 def SubscriptionPolledRefresh(self, request):
00048 def SubscriptionCancel(self, request):
00049 def GetStatus(self, request):
00050 def Browse(self, request):
00051 def Read(self, request):
00052 def Write(self, request):
00053 """
00054 name = "test_OpcDaGateway"
00055 client_file_name = "OpcXmlDaSrv_client.py"
00056 types_file_name = "OpcXmlDaSrv_types.py"
00057 server_file_name = "OpcXmlDaSrv_server.py"
00058
00059 def __init__(self, methodName):
00060 ServiceTestCase.__init__(self, methodName)
00061 self.wsdl2py_args.append('-b')
00062
00063 def test_local_anyType(self):
00064 """serialize an int via anyType, then parse it back.
00065 """
00066 import time
00067 pyobj = self.client_module.ReadSoapOut()
00068 pyobj.RItemList = pyobj.new_RItemList()
00069 item = pyobj.RItemList.new_Items()
00070 pyobj.RItemList.Items = [item,]
00071 item.typecode.ofwhat[1].processContents = 'lax'
00072 item.Value = 123
00073 s = str(ZSI.SoapWriter().serialize(pyobj))
00074
00075 ps = ZSI.ParsedSoap(s)
00076 pyobj = ps.Parse(pyobj.typecode)
00077 for item in pyobj.RItemList.Items:
00078 item.Value
00079
00080 def test_net_Browse(self):
00081 """FaultException: The item path is not known to the server.
00082 """
00083 loc = self.client_module.OpcXmlDaSrvLocator()
00084 port = loc.getOpcXmlDaSrvSoap(**self.getPortKWArgs())
00085
00086 msg = self.client_module.BrowseSoapIn()
00087 msg._PropertyNames=['Static']
00088 msg._attrs = {'ItemPath':'Static'}
00089
00090 self.failUnless(\
00091 getattr(msg.typecode, 'attribute_typecode_dict', None) is not None,
00092 )
00093
00094 self.failUnlessRaises(FaultException, port.Browse, msg)
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 if __name__ == "__main__" :
00154 main()
00155