Commit b2ee9084 authored by Olivier R-D's avatar Olivier R-D

add tests for data type and null node value

parent 3faa3c4c
......@@ -20,6 +20,9 @@ class MonitoredItemData(object):
class MonitoredItemService(object):
"""
implement monitoreditem service for 1 subscription
"""
def __init__(self, isub, aspace):
self.logger = logging.getLogger(__name__ + str(isub.data.SubscriptionId))
......
......@@ -49,6 +49,13 @@ class Node(object):
result = self.get_attribute(ua.AttributeIds.DisplayName)
return result.Value
def get_data_type(self):
"""
get data type of node
"""
result = self.get_attribute(ua.AttributeIds.DataType)
return result.Value
def get_node_class(self):
"""
get node class attribute of node
......
......@@ -353,6 +353,27 @@ class CommonTests(object):
self.assertEqual(nid, v.nodeid)
self.assertEqual(qn, v.get_browse_name())
def test_null_variable(self):
objects = self.opc.get_objects_node()
var = objects.add_variable(3, 'nullstring', "a string")
var.set_value(None)
val = var.get_value()
self.assertEqual(val, None)
var.set_value("")
val = var.get_value()
self.assertNotEqual(val, None)
self.assertEqual(val, "")
def test_variable_data_type(self):
objects = self.opc.get_objects_node()
var = objects.add_variable(3, 'stringfordatatype', "a string")
val = var.get_data_type()
self.assertEqual(val, ua.NodeId(ua.ObjectIds.String))
var = objects.add_variable(3, 'stringarrayfordatatype', ["a", "b"])
val = var.get_data_type()
self.assertEqual(val, ua.NodeId(ua.ObjectIds.String))
def test_add_string_array_variable(self):
objects = self.opc.get_objects_node()
v = objects.add_variable('ns=3;s=stringarrayid;', '9:stringarray', ['l', 'b'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment