Commit 7d735413 authored by oroulet's avatar oroulet Committed by oroulet

fix more tests

parent 00c1148a
...@@ -322,4 +322,4 @@ class XmlElement(FrozenClass): ...@@ -322,4 +322,4 @@ class XmlElement(FrozenClass):
:vartype Value: String :vartype Value: String
""" """
Value: uatypes.String Value: uatypes.String = ""
...@@ -614,10 +614,6 @@ class LocalizedText: ...@@ -614,10 +614,6 @@ class LocalizedText:
) )
def to_string(self): def to_string(self):
if self.Text is None:
return ""
if self.Locale is None:
return self.Text
return self.__str__() return self.__str__()
@staticmethod @staticmethod
......
...@@ -131,7 +131,6 @@ def test_custom_structs_array(tmpdir): ...@@ -131,7 +131,6 @@ def test_custom_structs_array(tmpdir):
data = struct_to_binary(v) data = struct_to_binary(v)
v2 = struct_from_binary(ns["ArrayValueDataType"], ua.utils.Buffer(data)) v2 = struct_from_binary(ns["ArrayValueDataType"], ua.utils.Buffer(data))
assert v.NodeIdValue == v2.NodeIdValue assert v.NodeIdValue == v2.NodeIdValue
# print(v2.NodeIdValue)
def test_nodeid_nsu(): def test_nodeid_nsu():
...@@ -140,7 +139,6 @@ def test_nodeid_nsu(): ...@@ -140,7 +139,6 @@ def test_nodeid_nsu():
n2 = nodeid_from_binary(ua.utils.Buffer(data)) n2 = nodeid_from_binary(ua.utils.Buffer(data))
assert n1 == n2 assert n1 == n2
string = n1.to_string() string = n1.to_string()
print(string)
n3 = ua.NodeId.from_string(string) n3 = ua.NodeId.from_string(string)
assert n1 == n3 assert n1 == n3
...@@ -237,7 +235,6 @@ def test_string_to_variant_localized_text_with_locale(): ...@@ -237,7 +235,6 @@ def test_string_to_variant_localized_text_with_locale():
string_repr = f'LocalizedText(Encoding:3, Locale:{locale}, Text:{string})' string_repr = f'LocalizedText(Encoding:3, Locale:{locale}, Text:{string})'
obj = ua.LocalizedText(string, locale) obj = ua.LocalizedText(string, locale)
assert obj == string_to_val(string_repr, ua.VariantType.LocalizedText) assert obj == string_to_val(string_repr, ua.VariantType.LocalizedText)
breakpoint()
assert string_repr == val_to_string(obj) assert string_repr == val_to_string(obj)
...@@ -611,9 +608,7 @@ def test_text(): ...@@ -611,9 +608,7 @@ def test_text():
def test_text_simple(): def test_text_simple():
t = ua.LocalizedText('Root') t = ua.LocalizedText('Root')
b = struct_to_binary(t) b = struct_to_binary(t)
print("BIN", b)
buf = ua.utils.Buffer(b) buf = ua.utils.Buffer(b)
print("BUF", buf)
t2 = struct_from_binary(ua.LocalizedText, buf) t2 = struct_from_binary(ua.LocalizedText, buf)
assert t == t2 assert t == t2
...@@ -742,3 +737,12 @@ def test_bin_data_type_def(): ...@@ -742,3 +737,12 @@ def test_bin_data_type_def():
ad2 = struct_from_binary(ua.AddNodesItem, ua.utils.Buffer(data)) ad2 = struct_from_binary(ua.AddNodesItem, ua.utils.Buffer(data))
assert ad.ParentNodeId == ad2.ParentNodeId assert ad.ParentNodeId == ad2.ParentNodeId
assert ad.NodeAttributes.DisplayName == ad2.NodeAttributes.DisplayName assert ad.NodeAttributes.DisplayName == ad2.NodeAttributes.DisplayName
def test_bin_datattributes():
dta = ua.DataTypeAttributes()
dta.DisplayName = ua.LocalizedText("titi")
data = struct_to_binary(dta)
dta2 = struct_from_binary(ua.DataTypeAttributes, ua.utils.Buffer(data))
assert dta.DisplayName == dta2.DisplayName
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