Skip to content

Commit

Permalink
Working system test for count plan
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Feb 3, 2025
1 parent b605942 commit 53801cd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/blueapi/startup/example_devices.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
from pathlib import Path
from tempfile import TemporaryDirectory

from dodal.common.beamlines.beamline_utils import set_path_provider
from dodal.common.visit import LocalDirectoryServiceClient, StaticVisitPathProvider
from ophyd.sim import Syn2DGauss, SynGauss, SynSignal

from .simmotor import BrokenSynAxis, SynAxisWithMotionEvents

# Some of our plans such as "count" and "spec_scan" require this global
# singleton to be set
_tmp_dir = Path(TemporaryDirectory().name)
set_path_provider(
StaticVisitPathProvider(
"t01",
_tmp_dir,
client=LocalDirectoryServiceClient(),
)
)


def x(name="x") -> SynAxisWithMotionEvents:
return SynAxisWithMotionEvents(name=name, delay=1.0, events_per_move=8)
Expand Down
38 changes: 33 additions & 5 deletions tests/system_tests/test_blueapi_system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import textwrap
import time
from pathlib import Path

Expand Down Expand Up @@ -337,11 +338,38 @@ def test_get_current_state_of_environment(client: BlueapiClient):
assert client.get_environment().initialized


@pytest.mark.skip(
reason=textwrap.dedent("""
The client should block until environment reload is complete but it does not,
this interferes with subsequent tests. See
https://github.com/DiamondLightSource/blueapi/issues/742
""")
)
def test_delete_current_environment(client: BlueapiClient):
current_env = client.get_environment()
old_env = client.get_environment()
client.reload_environment()
new_env = client.get_environment()
assert (
new_env.initialized is True
and new_env.environment_id != current_env.environment_id
)
assert new_env.initialized
assert new_env.environment_id != old_env.environment_id
assert new_env.error_message is None


@pytest.mark.parametrize(
"task",
[
Task(
name="count",
params={
"detectors": [
"image_det",
"current_det",
],
"num": 5,
},
)
],
)
def test_plan_runs(client_with_stomp: BlueapiClient, task: Task):
final_event = client_with_stomp.run_task(task)
assert final_event.is_complete() and not final_event.is_error()
assert final_event.state is WorkerState.IDLE

0 comments on commit 53801cd

Please sign in to comment.