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
51826f9f
Commit
51826f9f
authored
Nov 24, 2017
by
Mathias Lüdtke
Committed by
oroulet
Nov 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved method tests
test for tuple and None return values
parent
43436b74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
tests/tests_common.py
tests/tests_common.py
+27
-3
No files found.
tests/tests_common.py
View file @
51826f9f
...
...
@@ -12,7 +12,7 @@ from opcua import uamethod
from
opcua
import
instantiate
from
opcua
import
copy_node
from
opcua.common
import
ua_utils
from
opcua.common.methods
import
call_method_full
def
add_server_methods
(
srv
):
@
uamethod
...
...
@@ -45,7 +45,7 @@ def add_server_methods(srv):
@
uamethod
def
func4
(
parent
):
return
[]
return
None
base_otype
=
srv
.
get_node
(
ua
.
ObjectIds
.
BaseObjectType
)
custom_otype
=
base_otype
.
add_object_type
(
2
,
'ObjectWithMethodsType'
)
...
...
@@ -55,6 +55,11 @@ def add_server_methods(srv):
custom_otype
.
add_method
(
2
,
'ServerMethodNone'
,
func4
).
set_modelling_rule
(
None
)
o
.
add_object
(
2
,
'ObjectWithMethods'
,
custom_otype
)
@
uamethod
def
func5
(
parent
):
return
1
,
2
,
3
o
=
srv
.
get_objects_node
()
v
=
o
.
add_method
(
ua
.
NodeId
(
"ServerMethodTuple"
,
2
),
ua
.
QualifiedName
(
'ServerMethodTuple'
,
2
),
func5
,
[],
[
ua
.
VariantType
.
Int64
,
ua
.
VariantType
.
Int64
,
ua
.
VariantType
.
Int64
])
def
_test_modelling_rules
(
test
,
parent
,
mandatory
,
result
):
f
=
parent
.
add_folder
(
3
,
'MyFolder'
)
...
...
@@ -563,6 +568,25 @@ class CommonTests(object):
m
=
o
.
get_child
(
"2:ServerMethodArray2"
)
result
=
o
.
call_method
(
m
,
[
1.1
,
3.4
,
9
])
self
.
assertEqual
(
result
,
[
2.2
,
6.8
,
18
])
result
=
call_method_full
(
o
,
m
,
[
1.1
,
3.4
,
9
])
self
.
assertEqual
(
result
.
OutputArguments
,
[[
2.2
,
6.8
,
18
]])
def
test_method_tuple
(
self
):
o
=
self
.
opc
.
get_objects_node
()
m
=
o
.
get_child
(
"2:ServerMethodTuple"
)
result
=
o
.
call_method
(
m
)
self
.
assertEqual
(
result
,
[
1
,
2
,
3
])
result
=
call_method_full
(
o
,
m
)
self
.
assertEqual
(
result
.
OutputArguments
,
[
1
,
2
,
3
])
def
test_method_none
(
self
):
# this test calls the function linked to the type's method..
o
=
self
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseObjectType
).
get_child
(
"2:ObjectWithMethodsType"
)
m
=
o
.
get_child
(
"2:ServerMethodDefault"
)
result
=
o
.
call_method
(
m
)
self
.
assertEqual
(
result
,
None
)
result
=
call_method_full
(
o
,
m
)
self
.
assertEqual
(
result
.
OutputArguments
,
[])
def
test_add_nodes
(
self
):
objects
=
self
.
opc
.
get_objects_node
()
...
...
@@ -605,7 +629,7 @@ class CommonTests(object):
self
.
assertEqual
(
m
.
get_referenced_nodes
(
ua
.
ObjectIds
.
HasModellingRule
),
result
)
objects
=
self
.
opc
.
get_objects_node
()
objects
.
get_child
([
'2:ObjectWithMethods'
,
'2:ServerMethodDefault'
])
c
=
objects
.
get_child
([
'2:ObjectWithMethods'
,
'2:ServerMethodDefault'
])
def
test_add_nodes_modelling_rules_type_true
(
self
):
base_otype
=
self
.
opc
.
get_node
(
ua
.
ObjectIds
.
BaseObjectType
)
...
...
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