tests_cmd_lines.py
Go to the documentation of this file.
00001 import unittest
00002 import subprocess
00003 
00004 from opcua import Server
00005 
00006 
00007 port_num = 48530
00008 
00009 
00010 class TestCmdLines(unittest.TestCase):
00011 
00012     '''
00013     Test command lines
00014     '''
00015     @classmethod
00016     def setUpClass(cls):
00017         cls.srv = Server()
00018         cls.srv_url = 'opc.tcp://localhost:{0:d}'.format(port_num)
00019         cls.srv.set_endpoint(cls.srv_url)
00020         objects = cls.srv.get_objects_node()
00021         obj = objects.add_object(4, "directory")
00022         var = obj.add_variable(4, "variable", 1.999)
00023         var2 = obj.add_variable(4, "variable2", 1.777)
00024         var2.set_writable()
00025         cls.srv.start()
00026 
00027     def test_uals(self):
00028         s = subprocess.check_output(["python", "tools/uals", "--url", self.srv_url])
00029         self.assertIn(b"i=85", s)
00030         self.assertNotIn(b"i=89", s)
00031         self.assertNotIn(b"1.999", s)
00032         s = subprocess.check_output(["python", "tools/uals", "--url", self.srv_url, "-d", "3"])
00033         self.assertIn(b"1.999", s)
00034 
00035     def test_uaread(self):
00036         s = subprocess.check_output(["python", "tools/uaread", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable"])
00037         self.assertIn(b"1.999", s)
00038 
00039     def test_uawrite(self):
00040         s = subprocess.check_output(["python", "tools/uawrite", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable2", "1.789"])
00041         s = subprocess.check_output(["python", "tools/uaread", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable2"])
00042         self.assertIn(b"1.789", s)
00043         self.assertNotIn(b"1.999", s)
00044 
00045     def test_uadiscover(self):
00046         s = subprocess.check_output(["python", "tools/uadiscover", "--url", self.srv_url])
00047         self.assertIn(b"opc.tcp://localhost", s)
00048         self.assertIn(b"FreeOpcUa", s)
00049         self.assertIn(b"urn:freeopcua:python:server", s)
00050 
00051     @classmethod
00052     def tearDownClass(cls):
00053         cls.srv.stop()
00054 
00055 


ros_opcua_impl_python_opcua
Author(s): Denis Štogl , Daniel Draper
autogenerated on Sat Jun 8 2019 18:26:23