Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
1f332120
Commit
1f332120
authored
May 19, 2019
by
jikalousek
Committed by
oroulet
May 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests were implemented to validate the changes regarding the localized text feature.
parent
45d55f01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
tests/test_unit.py
tests/test_unit.py
+41
-1
tests/test_xml.py
tests/test_xml.py
+8
-0
No files found.
tests/test_unit.py
View file @
1f332120
...
...
@@ -228,7 +228,33 @@ def test_string_to_variant_localized_text():
obj
=
ua
.
LocalizedText
(
string
)
assert
obj
==
string_to_val
(
string
,
ua
.
VariantType
.
LocalizedText
)
assert
string
==
val_to_string
(
obj
)
def
test_string_to_variant_localized_text_with_locale
():
locale
=
"cs-CZ"
string
=
"Moje jméno"
string_repr
=
"LocalizedText(Encoding:3, Locale:{}, Text:{})"
.
format
(
locale
,
string
)
obj
=
ua
.
LocalizedText
(
string
,
locale
)
assert
obj
==
string_to_val
(
string_repr
,
ua
.
VariantType
.
LocalizedText
)
assert
string_repr
==
val_to_string
(
obj
)
def
test_string_to_variant_localized_text_with_none1
():
locale
=
"en-US"
string
=
""
string_repr
=
"LocalizedText(Encoding:1, Locale:{}, Text:{})"
.
format
(
locale
,
string
)
obj
=
ua
.
LocalizedText
(
string
,
locale
)
obj2
=
ua
.
LocalizedText
(
string
)
assert
obj
==
string_to_val
(
string_repr
,
ua
.
VariantType
.
LocalizedText
)
assert
obj2
==
string_to_val
(
string
,
ua
.
VariantType
.
LocalizedText
)
assert
""
==
val_to_string
(
obj
)
def
test_string_to_variant_localized_text_with_none2
():
locale
=
None
string
=
"my name is ..."
string_repr
=
"LocalizedText(Encoding:2, Locale:{}, Text:{})"
.
format
(
locale
,
string
)
obj
=
ua
.
LocalizedText
(
string
,
locale
)
assert
obj
==
string_to_val
(
string_repr
,
ua
.
VariantType
.
LocalizedText
)
assert
obj
==
string_to_val
(
string
,
ua
.
VariantType
.
LocalizedText
)
assert
string
==
val_to_string
(
obj
)
def
test_string_to_val_xml_element
():
string
=
"<p> titi toto </p>"
...
...
@@ -550,6 +576,20 @@ def test_text():
t4
=
struct_from_binary
(
ua
.
LocalizedText
,
ua
.
utils
.
Buffer
(
struct_to_binary
(
t1
)))
assert
t1
==
t4
def
test_text_with_locale
():
t0
=
ua
.
LocalizedText
(
'Root'
)
t1
=
ua
.
LocalizedText
(
'Root'
,
'de-AT'
)
t2
=
ua
.
LocalizedText
(
'Root'
,
'de-AT'
)
t3
=
ua
.
LocalizedText
(
'Root'
,
'de-DE'
)
t4
=
ua
.
LocalizedText
(
locale
=
'de-DE'
)
t5
=
ua
.
LocalizedText
(
locale
=
'de-DE'
)
assert
t0
!=
t1
assert
t1
==
t2
assert
t1
!=
t3
assert
t3
!=
t4
assert
t4
==
t5
t6
=
struct_from_binary
(
ua
.
LocalizedText
,
ua
.
utils
.
Buffer
(
struct_to_binary
(
t1
)))
assert
t1
==
t6
def
test_message_chunk
():
pol
=
ua
.
SecurityPolicy
()
...
...
tests/test_xml.py
View file @
1f332120
...
...
@@ -244,12 +244,20 @@ async def test_xml_localizedtext(opc, tmpdir):
o
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
2
,
"xmlltext"
,
ua
.
LocalizedText
(
"mytext"
))
await
_test_xml_var_type
(
opc
,
tmpdir
,
o
,
"localized_text"
)
async
def
test_xml_localizedtext_with_locale
(
opc
,
tmpdir
):
o
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
2
,
"xmlltext"
,
ua
.
LocalizedText
(
"mytext"
,
"en-US"
))
await
_test_xml_var_type
(
opc
,
tmpdir
,
o
,
"localized_text"
)
async
def
test_xml_localizedtext_array
(
opc
,
tmpdir
):
o
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
2
,
"xmlltext_array"
,
[
ua
.
LocalizedText
(
"erert"
),
ua
.
LocalizedText
(
"erert33"
)])
await
_test_xml_var_type
(
opc
,
tmpdir
,
o
,
"localized_text_array"
)
async
def
test_xml_localizedtext_array_with_locale
(
opc
,
tmpdir
):
o
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
2
,
"xmlltext_array"
,
[
ua
.
LocalizedText
(
text
=
"erert"
,
locale
=
"en"
),
ua
.
LocalizedText
(
text
=
"erert33"
,
locale
=
"de"
)])
await
_test_xml_var_type
(
opc
,
tmpdir
,
o
,
"localized_text_array"
)
async
def
test_xml_nodeid
(
opc
,
tmpdir
):
o
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
2
,
"xmlnodeid"
,
ua
.
NodeId
(
"mytext"
,
1
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment