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
1aaa41aa
Commit
1aaa41aa
authored
Apr 12, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing file
parent
f9c6f189
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
tests/tests_history.py
tests/tests_history.py
+98
-0
No files found.
tests/tests_history.py
0 → 100644
View file @
1aaa41aa
import
time
from
datetime
import
datetime
,
timedelta
import
unittest
from
opcua
import
Client
from
opcua
import
Server
from
opcua
import
ua
from
opcua.server.history_sql
import
HistorySQLite
from
tests_common
import
CommonTests
,
add_server_methods
port_num1
=
48530
port_num2
=
48530
class
HistoryCommon
(
object
):
srv
=
Server
clt
=
Client
def
test_history_read
(
self
):
o
=
self
.
srv
.
get_objects_node
()
vals
=
[
i
for
i
in
range
(
20
)]
var
=
o
.
add_variable
(
3
,
"history_var"
,
0
)
self
.
srv
.
iserver
.
enable_history
(
var
,
period
=
None
,
count
=
10
)
for
i
in
vals
:
var
.
set_value
(
i
)
time
.
sleep
(
1
)
now
=
datetime
.
now
()
old
=
now
-
timedelta
(
days
=
6
)
res
=
var
.
read_raw_history
(
None
,
now
,
2
)
self
.
assertEqual
(
len
(
res
),
2
)
self
.
assertEqual
(
res
[
-
1
].
Value
.
Value
,
vals
[
-
1
])
res
=
var
.
read_raw_history
(
old
,
now
,
0
)
self
.
assertEqual
(
len
(
res
),
20
)
self
.
assertEqual
(
res
[
-
1
].
Value
.
Value
,
vals
[
-
1
])
self
.
assertEqual
(
res
[
0
].
Value
.
Value
,
vals
[
0
])
res
=
var
.
read_raw_history
(
old
,
now
,
5
)
self
.
assertEqual
(
len
(
res
),
5
)
self
.
assertEqual
(
res
[
-
1
].
Value
.
Value
,
vals
[
4
])
self
.
assertEqual
(
res
[
0
].
Value
.
Value
,
vals
[
0
])
class
TestHistory
(
unittest
.
TestCase
,
HistoryCommon
):
'''
'''
@
classmethod
def
setUpClass
(
self
):
# start our own server
self
.
srv
=
Server
()
self
.
srv
.
set_endpoint
(
'opc.tcp://localhost:%d'
%
port_num1
)
self
.
srv
.
start
()
# start anonymous client
self
.
clt
=
Client
(
'opc.tcp://localhost:%d'
%
port_num1
)
self
.
clt
.
connect
()
@
classmethod
def
tearDownClass
(
self
):
self
.
clt
.
disconnect
()
self
.
srv
.
stop
()
class
TestHistorySQL
(
unittest
.
TestCase
,
HistoryCommon
):
'''
'''
@
classmethod
def
setUpClass
(
self
):
# start our own server
self
.
srv
=
Server
()
self
.
srv
.
set_endpoint
(
'opc.tcp://localhost:%d'
%
port_num1
)
self
.
srv
.
iserver
.
history_manager
.
set_storage
(
HistorySQLite
())
self
.
srv
.
start
()
# start anonymous client
self
.
clt
=
Client
(
'opc.tcp://localhost:%d'
%
port_num1
)
self
.
clt
.
connect
()
@
classmethod
def
tearDownClass
(
self
):
self
.
clt
.
disconnect
()
self
.
srv
.
stop
()
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