Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions tests/unit_tests/core/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from dodal.common import PlanGenerator, inject
from ophyd_async.core import (
StandardDetector,
StandardReadable,
StaticPathProvider,
UUIDFilenameProvider,
init_devices,
Expand Down Expand Up @@ -126,15 +127,35 @@ def sim_detector(tmp_path: Path) -> StandardDetector:
return sim_det


class SimStage(StandardReadable):
def __init__(self, name: str = "") -> None:
with self.add_children_as_readables():
self.x = Motor("BAZ:")
self.y = Motor("BLARG:")
super().__init__(name)


@pytest.fixture
def sim_stage(RE: RunEngine) -> SimStage:
with init_devices(mock=True):
sim_stage = SimStage()
return sim_stage


@pytest.fixture
def empty_context() -> BlueskyContext:
return BlueskyContext()


@pytest.fixture
def devicey_context(sim_motor: Motor, sim_detector: StandardDetector) -> BlueskyContext:
def devicey_context(
sim_motor: Motor,
sim_stage: SimStage,
sim_detector: StandardDetector,
) -> BlueskyContext:
ctx = BlueskyContext()
ctx.register_device(sim_motor)
ctx.register_device(sim_stage)
ctx.register_device(sim_detector)
return ctx

Expand Down Expand Up @@ -168,7 +189,11 @@ def demo_plan(foo: int, mov: Movable) -> MsgGenerator:
schema = devicey_context.plans["demo_plan"].model.model_json_schema()
assert schema["properties"] == {
"foo": {"title": "Foo", "type": "integer"},
"mov": {"title": "Mov", "type": "bluesky.protocols.Movable", "enum": ["sim"]},
"mov": {
"title": "Mov",
"type": "bluesky.protocols.Movable",
"enum": ["sim", "sim_stage.x", "sim_stage.y"],
},
}


Expand Down
Loading