Skip to content

Commit 3e02728

Browse files
committed
CI: add custom simulated IOC
1 parent 4539b8a commit 3e02728

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

ioc/sim_ioc.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ class SimpleIOC(PVGroup):
1717
C (array of int)
1818
"""
1919

20-
A = pvproperty(
21-
value=1,
22-
doc="An integer",
23-
)
24-
B = pvproperty(value=2.0, doc="A float")
25-
C = pvproperty(value=[1, 2, 3], doc="An array of integers (max length 3)")
20+
A = pvproperty(value=1.0, doc="Value A")
21+
B = pvproperty(value=1.0, doc="Value B")
22+
C = pvproperty(value=1.0, doc="Value C")
23+
D = pvproperty(value=1.0, doc="Value D")
24+
E = pvproperty(value=1.0, doc="Value E")
25+
F = pvproperty(value=1.0, doc="Value F")
26+
G = pvproperty(value=1.0, doc="Value G")
27+
H = pvproperty(value=1.0, doc="Value H")
28+
I = pvproperty(value=1.0, doc="Value I") # noqa:E741
29+
J = pvproperty(value=1.0, doc="Value J")
2630

2731

2832
if __name__ == "__main__":
29-
ioc_options, run_options = ioc_arg_parser(default_prefix="simple:", desc=dedent(SimpleIOC.__doc__))
33+
ioc_options, run_options = ioc_arg_parser(default_prefix="simulated:", desc=dedent(SimpleIOC.__doc__))
3034
ioc = SimpleIOC(**ioc_options)
3135
run(ioc.pvdb, **run_options)

tests/common.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,28 @@ def _clear():
108108
_clear()
109109
yield
110110
_clear()
111+
112+
113+
@pytest.fixture
114+
def ioc():
115+
"""
116+
Reset simulated IOC to initial values before and after the test
117+
"""
118+
119+
def _reset_ioc():
120+
from epics import caput
121+
122+
caput("simulated:A", 1.0)
123+
caput("simulated:B", 2.0)
124+
caput("simulated:C", 3.0)
125+
caput("simulated:D", 4.0)
126+
caput("simulated:E", 5.0)
127+
caput("simulated:F", 6.0)
128+
caput("simulated:G", 7.0)
129+
caput("simulated:H", 8.0)
130+
caput("simulated:I", 9.0)
131+
caput("simulated:J", 10.0)
132+
133+
_reset_ioc()
134+
yield
135+
_reset_ioc()

tests/test_misc.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
admin_username,
1616
base_url,
1717
clear_sar, # noqa: F401
18+
ioc, # noqa: F401
1819
read_password,
1920
read_username,
2021
user_password,
@@ -103,8 +104,15 @@ async def testing():
103104

104105

105106

106-
def test_epics():
107+
def test_epics(ioc): # noqa: F811
107108
import epics
108-
epics.caput("simple:A", 10)
109-
v = epics.caget("simple:A")
110-
assert v == 10
109+
assert epics.caget("simulated:A") == 1.0
110+
assert epics.caget("simulated:B") == 2.0
111+
assert epics.caget("simulated:C") == 3.0
112+
assert epics.caget("simulated:D") == 4.0
113+
assert epics.caget("simulated:E") == 5.0
114+
assert epics.caget("simulated:F") == 6.0
115+
assert epics.caget("simulated:G") == 7.0
116+
assert epics.caget("simulated:H") == 8.0
117+
assert epics.caget("simulated:I") == 9.0
118+
assert epics.caget("simulated:J") == 10.0

0 commit comments

Comments
 (0)