Skip to content

Commit 2e8842f

Browse files
authored
test: Make use of Sim to speedup test (#1425)
1 parent 06bee20 commit 2e8842f

File tree

4 files changed

+64
-15
lines changed

4 files changed

+64
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ requires-python = ">=3.11"
4545

4646
[dependency-groups]
4747
dev = [
48+
"ophyd_async[sim]",
4849
"copier",
4950
"myst-parser",
5051
"prek",

tests/unit_tests/code_examples/device_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
from dodal.devices.bimorph_mirror import BimorphMirror
33

44

5-
@device_factory()
5+
@device_factory(mock=True)
66
def oav() -> BimorphMirror:
77
return BimorphMirror("BLXXI-BMRPH-01:", number_of_channels=8)

tests/unit_tests/core/fake_device_module.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
from dodal.common.beamlines.beamline_utils import device_factory
44
from dodal.utils import OphydV1Device, OphydV2Device
55
from ophyd_async.core import DEFAULT_TIMEOUT, LazyMock, StandardReadable
6-
from ophyd_async.epics.motor import Motor
6+
from ophyd_async.sim import SimMotor
77

88

99
def fake_motor_bundle_b(
10-
fake_motor_x: Motor,
11-
fake_motor_y: Motor,
12-
) -> Motor:
13-
return Motor("BAR:", "motor_bundle_b")
10+
fake_motor_x: SimMotor,
11+
fake_motor_y: SimMotor,
12+
) -> SimMotor:
13+
return SimMotor("motor_bundle_b")
1414

1515

16-
def fake_motor_x() -> Motor:
17-
return Motor("FOO:", "motor_x")
16+
def fake_motor_x() -> SimMotor:
17+
return SimMotor("motor_x")
1818

1919

2020
class DeviceA(StandardReadable):
2121
def __init__(self, name: str = "") -> None:
2222
with self.add_children_as_readables():
23-
self.motor = Motor("X:SIZE")
23+
self.motor = SimMotor("X:SIZE")
2424
super().__init__(name)
2525

2626

@@ -56,15 +56,15 @@ def ophyd_async_device() -> UnconnectableOphydAsyncDevice:
5656
return UnconnectableOphydAsyncDevice(name="ophyd_async_device")
5757

5858

59-
def fake_motor_y() -> Motor:
60-
return Motor("BAZ:", "motor_y")
59+
def fake_motor_y() -> SimMotor:
60+
return SimMotor("motor_y")
6161

6262

6363
def fake_motor_bundle_a(
64-
fake_motor_x: Motor,
65-
fake_motor_y: Motor,
66-
) -> Motor:
67-
return Motor("QUX:", "motor_bundle_a")
64+
fake_motor_x: SimMotor,
65+
fake_motor_y: SimMotor,
66+
) -> SimMotor:
67+
return SimMotor("motor_bundle_a")
6868

6969

7070
def wrong_return_type() -> int:

uv.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)