Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benoit Rousselle
bliss
Commits
a81da17e
Commit
a81da17e
authored
Oct 19, 2017
by
Matias Guijarro
Browse files
tests: first attempt to add tests for wago controller
parent
d9f6168a
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_configuration/wago.yml
0 → 100644
View file @
a81da17e
plugin
:
bliss
class
:
wago
name
:
wcid00
controller_ip
:
localhost
mapping
:
-
type
:
750-530
logical_names
:
attctrl,_,attctrl,_,attctrl,_,attctrl,_
-
type
:
750-530
logical_names
:
attctrl,detcover_ctrl,attctrl,_,attctrl, _,attctrl,_
-
type
:
750-436
logical_names
:
attstatus,attstatus,attstatus,attstatus,attstatus,attstatus,attstatus,attstatus
tests/wago/test_wago.py
0 → 100644
View file @
a81da17e
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import
pytest
import
time
import
mock
import
inspect
def
read_coils
(
what
,
size
):
print
"read coils"
,
what
,
size
cc
=
inspect
.
currentframe
().
f_back
print
"modules to read"
,
cc
.
f_locals
[
"modules_to_read"
]
print
"mapping"
,
cc
.
f_locals
[
"self"
].
mapping
if
what
==
512
:
# IN
return
[
0
]
*
size
else
:
# OUT
return
[
1
]
*
size
def
write_coil
(
*
args
,
**
kwargs
):
print
"write coil"
,
args
,
kwargs
def
read_input_registers
(
*
args
,
**
kwargs
):
print
"read input registers"
,
args
,
kwargs
def
write_register
(
*
args
,
**
kwargs
):
print
"write register"
,
args
,
kwargs
def
test_wago
(
beacon
):
w
=
beacon
.
get
(
"wcid00"
)
w
.
connect
()
with
mock
.
patch
.
object
(
w
.
controller
.
client
,
"read_coils"
,
read_coils
):
with
mock
.
patch
.
object
(
w
.
controller
.
client
,
"read_input_registers"
,
read_input_registers
):
with
mock
.
patch
.
object
(
w
.
controller
.
client
,
"write_coil"
,
write_coil
):
with
mock
.
patch
.
object
(
w
.
controller
.
client
,
"write_register"
,
write_register
):
print
w
.
get
(
"attctrl"
,
"attstatus"
)
#w.set("attctrl", *[1]*8)
Write
Preview
Supports
Markdown
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