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
9012c82f
Commit
9012c82f
authored
Nov 12, 2017
by
Mathias Lüdtke
Committed by
oroulet
Nov 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for references in standard address space
parent
78d61807
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
tests/tests.py
tests/tests.py
+1
-0
tests/tests_standard_address_space.py
tests/tests_standard_address_space.py
+62
-0
No files found.
tests/tests.py
View file @
9012c82f
...
...
@@ -8,6 +8,7 @@ sys.path.insert(0, ".")
from
tests_cmd_lines
import
TestCmdLines
from
tests_server
import
TestServer
,
TestServerCaching
,
TestServerStartError
from
tests_client
import
TestClient
from
tests_standard_address_space
import
StandardAddressSpaceTests
from
tests_unit
import
TestUnit
,
TestMaskEnum
from
tests_history
import
TestHistory
,
TestHistorySQL
,
TestHistoryLimits
,
TestHistorySQLLimits
from
tests_crypto_connect
import
TestCryptoConnect
...
...
tests/tests_standard_address_space.py
0 → 100644
View file @
9012c82f
import
unittest
import
os.path
import
xml.etree.ElementTree
as
ET
from
opcua
import
ua
from
opcua.server.address_space
import
AddressSpace
from
opcua.server.address_space
import
NodeManagementService
from
opcua.server.standard_address_space
import
standard_address_space
def
find_elem
(
parent
,
name
,
ns
=
None
):
if
ns
is
None
:
try
:
return
parent
.
find
(
parent
.
tag
[
0
:
parent
.
tag
.
index
(
'}'
)
+
1
]
+
name
)
except
ValueError
:
return
parent
.
find
(
name
)
return
parent
.
find
(
ns
+
name
)
def
remove_elem
(
parent
,
name
):
e
=
find_elem
(
parent
,
name
)
if
e
is
not
None
:
parent
.
remove
(
e
)
def
try_apply
(
item
,
aliases
):
attrib
=
item
.
attrib
for
name
in
(
'ReferenceType'
,
'DataType'
):
try
:
value
=
attrib
[
name
]
attrib
[
name
]
=
aliases
[
value
]
except
KeyError
:
pass
def
read_nodes
(
path
):
tree
=
ET
.
parse
(
path
)
root
=
tree
.
getroot
()
aliases_elem
=
find_elem
(
root
,
'Aliases'
)
aliases
=
dict
(
(
a
.
attrib
[
'Alias'
],
a
.
text
)
for
a
in
aliases_elem
)
any
(
try_apply
(
i
,
aliases
)
for
i
in
root
.
iter
())
root
.
remove
(
aliases_elem
)
remove_elem
(
root
,
"Models"
)
remove_elem
(
root
,
"NamespaceUris"
)
return
dict
((
e
.
attrib
[
'NodeId'
],
e
)
for
e
in
root
)
def
get_refs
(
e
):
return
set
((
r
.
attrib
[
'ReferenceType'
],
r
.
text
,
r
.
attrib
.
get
(
'IsForward'
,
'true'
)
==
'true'
)
for
r
in
find_elem
(
e
,
'References'
))
class
StandardAddressSpaceTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
aspace
=
AddressSpace
()
self
.
node_mgt_service
=
NodeManagementService
(
self
.
aspace
)
standard_address_space
.
fill_address_space
(
self
.
node_mgt_service
)
def
test_std_address_space_references
(
self
):
std_nodes
=
read_nodes
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'schemas'
,
'Opc.Ua.NodeSet2.xml'
)))
for
k
in
self
.
aspace
.
keys
():
refs
=
set
((
r
.
ReferenceTypeId
.
to_string
(),
r
.
NodeId
.
to_string
(),
r
.
IsForward
)
for
r
in
self
.
aspace
[
k
].
references
)
xml_refs
=
set
((
r
.
attrib
[
'ReferenceType'
],
r
.
text
,
r
.
attrib
.
get
(
'IsForward'
,
'true'
)
==
'true'
)
for
r
in
find_elem
(
std_nodes
[
k
.
to_string
()],
'References'
))
self
.
assertTrue
(
len
(
xml_refs
-
refs
)
==
0
)
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