Skip to content

Commit

Permalink
Rewrite system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Jan 22, 2025
1 parent a05f760 commit ae27738
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 326 deletions.
74 changes: 0 additions & 74 deletions src/htss_rig_bluesky/plans/detector.py

This file was deleted.

8 changes: 8 additions & 0 deletions src/htss_rig_bluesky/plans/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
from scanspec.specs import Line
import logging

from ophyd_async.fastcs.panda import HDFPanda
from pathlib import Path
from dodal.beamlines.training_rig import TrainingRigSampleStage

def step_scan_diagnostic(detector: AravisDetector, panda: HDFPanda, sample_stage: TrainingRigSampleStage) -> MsgGenerator:
scanspec = Line(sample_stage.x, 0, 10, 10) * ~Line(sample_stage.theta, 0, 360, 4)
yield from spec_scan([detector], scanspec)

def detector_diagnostic(detector: AravisDetector) -> MsgGenerator:
diagnostic_fields = {component for _, component in detector.drv.children()}.union(
{component for _, component in detector.hdf.children()}
Expand Down
165 changes: 0 additions & 165 deletions src/htss_rig_bluesky/plans/exercise.py

This file was deleted.

61 changes: 0 additions & 61 deletions src/htss_rig_bluesky/plans/system_test.py

This file was deleted.

19 changes: 0 additions & 19 deletions tests/system_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,6 @@

from htss_rig_bluesky.names import BEAMLINE


@pytest.fixture
def task_definition() -> dict[str, Task]:
return {
"step_scan_plan": Task(
name="step_scan_plan",
params={"detectors": "det", "motor": "sample_stage.theta"},
),
"fly_and_collect_plan": Task(
name="fly_and_collect_plan",
params={"panda": "panda", "diff": "det"},
),
"log_scan_plan": Task(
name="log_scan_plan",
params={"detectors": "det", "motor": "sample_stage.x"},
),
}


@pytest.fixture
def config() -> ApplicationConfig:
if BEAMLINE == "p46":
Expand Down
24 changes: 17 additions & 7 deletions tests/system_tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@
from blueapi.core.bluesky_types import DataEvent
from blueapi.worker.event import TaskStatus, WorkerEvent, WorkerState
from blueapi.worker.task import Task

from htss_rig_bluesky.plans.diagnostic import motor_diagnostic, detector_diagnostic, step_scan_diagnostic
# Please export BEAMLINE=pXX before running the tests or add it in pyproject.toml

TASKS = [
Task(name=motor_diagnostic.__name__, params={
"motor": "sample_stage.x"
}),
Task(name=motor_diagnostic.__name__, params={
"motor": "sample_stage.theta"
}),
Task(name=detector_diagnostic.__name__, params={
"detector": "det"
}),
]

def _check_all_events(all_events: list[AnyEvent]):
assert (
Expand Down Expand Up @@ -54,21 +65,20 @@ def test_device_present(client: BlueapiClient, device: str):


@pytest.mark.parametrize(
"plan", ["step_scan_plan", "fly_and_collect_plan", "log_scan_plan"]
"task", TASKS
)
def test_spec_scan_task(
def test_plan_runs(
client: BlueapiClient,
task_definition: dict[str, Task],
plan: str,
task: Task,
):
assert client.get_plan(plan), f"In {plan} is available"
assert client.get_plan(task.plan), f"In {task.plan} is not available"

all_events: list[AnyEvent] = []

def on_event(event: AnyEvent):
all_events.append(event)

client.run_task(task_definition[plan], on_event=on_event)
client.run_task(task, on_event=on_event)

_check_all_events(all_events)

Expand Down

0 comments on commit ae27738

Please sign in to comment.