tests_cmd_lines.py
Go to the documentation of this file.
1 import unittest
2 import subprocess
3 
4 from opcua import Server
5 
6 
7 port_num = 48530
8 
9 
10 class TestCmdLines(unittest.TestCase):
11 
12  '''
13  Test command lines
14  '''
15  @classmethod
16  def setUpClass(cls):
17  cls.srv = Server()
18  cls.srv_url = 'opc.tcp://localhost:{0:d}'.format(port_num)
19  cls.srv.set_endpoint(cls.srv_url)
20  objects = cls.srv.get_objects_node()
21  obj = objects.add_object(4, "directory")
22  var = obj.add_variable(4, "variable", 1.999)
23  var2 = obj.add_variable(4, "variable2", 1.777)
24  var2.set_writable()
25  cls.srv.start()
26 
27  def test_uals(self):
28  s = subprocess.check_output(["python", "tools/uals", "--url", self.srv_url])
29  self.assertIn(b"i=85", s)
30  self.assertNotIn(b"i=89", s)
31  self.assertNotIn(b"1.999", s)
32  s = subprocess.check_output(["python", "tools/uals", "--url", self.srv_url, "-d", "3"])
33  self.assertIn(b"1.999", s)
34 
35  def test_uaread(self):
36  s = subprocess.check_output(["python", "tools/uaread", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable"])
37  self.assertIn(b"1.999", s)
38 
39  def test_uawrite(self):
40  s = subprocess.check_output(["python", "tools/uawrite", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable2", "1.789"])
41  s = subprocess.check_output(["python", "tools/uaread", "--url", self.srv_url, "--path", "0:Objects,4:directory,4:variable2"])
42  self.assertIn(b"1.789", s)
43  self.assertNotIn(b"1.999", s)
44 
45  def test_uadiscover(self):
46  s = subprocess.check_output(["python", "tools/uadiscover", "--url", self.srv_url])
47  self.assertIn(b"opc.tcp://localhost", s)
48  self.assertIn(b"FreeOpcUa", s)
49  self.assertIn(b"urn:freeopcua:python:server", s)
50 
51  @classmethod
52  def tearDownClass(cls):
53  cls.srv.stop()
54 
55 


ros_opcua_impl_python_opcua
Author(s): Denis Štogl , Daniel Draper
autogenerated on Tue Jan 19 2021 03:12:44