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
49e3d921
Commit
49e3d921
authored
Jul 31, 2016
by
Georg Schölly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for MaskEnum
parent
5d841b35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
tests/tests.py
tests/tests.py
+1
-1
tests/tests_unit.py
tests/tests_unit.py
+25
-0
No files found.
tests/tests.py
View file @
49e3d921
...
@@ -8,7 +8,7 @@ sys.path.insert(0, ".")
...
@@ -8,7 +8,7 @@ sys.path.insert(0, ".")
from
tests_cmd_lines
import
TestCmdLines
from
tests_cmd_lines
import
TestCmdLines
from
tests_server
import
TestServer
,
TestServerCaching
from
tests_server
import
TestServer
,
TestServerCaching
from
tests_client
import
TestClient
from
tests_client
import
TestClient
from
tests_unit
import
TestUnit
from
tests_unit
import
TestUnit
,
TestMaskEnum
from
tests_history
import
TestHistory
,
TestHistorySQL
,
TestHistoryLimits
,
TestHistorySQLLimits
from
tests_history
import
TestHistory
,
TestHistorySQL
,
TestHistoryLimits
,
TestHistorySQLLimits
from
tests_history
import
TestHistorySQL
from
tests_history
import
TestHistorySQL
from
tests_crypto_connect
import
TestCryptoConnect
from
tests_crypto_connect
import
TestCryptoConnect
...
...
tests/tests_unit.py
View file @
49e3d921
...
@@ -13,6 +13,7 @@ from opcua.server.internal_subscription import WhereClauseEvaluator
...
@@ -13,6 +13,7 @@ from opcua.server.internal_subscription import WhereClauseEvaluator
from
opcua.common.event_objects
import
BaseEvent
from
opcua.common.event_objects
import
BaseEvent
from
opcua.common.ua_utils
import
string_to_variant
,
variant_to_string
,
string_to_val
,
val_to_string
from
opcua.common.ua_utils
import
string_to_variant
,
variant_to_string
,
string_to_val
,
val_to_string
from
opcua.common.xmlparser
import
XMLParser
from
opcua.common.xmlparser
import
XMLParser
from
opcua.ua.uatypes
import
_MaskEnum
class
TestUnit
(
unittest
.
TestCase
):
class
TestUnit
(
unittest
.
TestCase
):
...
@@ -458,6 +459,30 @@ class TestUnit(unittest.TestCase):
...
@@ -458,6 +459,30 @@ class TestUnit(unittest.TestCase):
self
.
assertEqual
(
res4
,
'ns=2;i=1001'
)
self
.
assertEqual
(
res4
,
'ns=2;i=1001'
)
class
TestMaskEnum
(
unittest
.
TestCase
):
class
MyEnum
(
_MaskEnum
):
member1
=
0
member2
=
1
def
test_invalid_input
(
self
):
with
self
.
assertRaises
(
ValueError
):
self
.
MyEnum
(
12345
)
def
test_parsing
(
self
):
self
.
assertEqual
(
self
.
MyEnum
.
parse_bitfield
(
0b0
),
set
())
self
.
assertEqual
(
self
.
MyEnum
.
parse_bitfield
(
0b1
),
{
self
.
MyEnum
.
member1
})
self
.
assertEqual
(
self
.
MyEnum
.
parse_bitfield
(
0b10
),
{
self
.
MyEnum
.
member2
})
self
.
assertEqual
(
self
.
MyEnum
.
parse_bitfield
(
0b11
),
{
self
.
MyEnum
.
member1
,
self
.
MyEnum
.
member2
})
def
test_identity
(
self
):
bitfields
=
[
0b00
,
0b01
,
0b10
,
0b11
]
for
bitfield
in
bitfields
:
as_set
=
self
.
MyEnum
.
parse_bitfield
(
bitfield
)
back_to_bitfield
=
self
.
MyEnum
.
to_bitfield
(
as_set
)
self
.
assertEqual
(
back_to_bitfield
,
bitfield
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
logging
.
basicConfig
(
level
=
logging
.
WARN
)
logging
.
basicConfig
(
level
=
logging
.
WARN
)
...
...
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