diff --git a/src/blueapi/startup/example_devices.py b/src/blueapi/startup/example_devices.py index a472137dd..97c2df026 100644 --- a/src/blueapi/startup/example_devices.py +++ b/src/blueapi/startup/example_devices.py @@ -1,7 +1,24 @@ +from pathlib import Path + +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 + +# Workaround for https://github.com/DiamondLightSource/blueapi/issues/784 +_tmp_dir = Path("/does/not/exist") +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) diff --git a/tests/system_tests/test_blueapi_system.py b/tests/system_tests/test_blueapi_system.py index 9505381b1..cf9bb4fde 100644 --- a/tests/system_tests/test_blueapi_system.py +++ b/tests/system_tests/test_blueapi_system.py @@ -1,4 +1,5 @@ import inspect +import textwrap import time from pathlib import Path @@ -6,6 +7,7 @@ from bluesky_stomp.models import BasicAuthentication from pydantic import TypeAdapter from requests.exceptions import ConnectionError +from scanspec.specs import Line from blueapi.client.client import ( BlueapiClient, @@ -147,7 +149,7 @@ def test_get_plans(client: BlueapiClient, expected_plans: PlanResponse): retrieved_plans.plans.sort(key=lambda x: x.name) expected_plans.plans.sort(key=lambda x: x.name) - assert retrieved_plans == expected_plans + assert retrieved_plans.model_dump() == expected_plans.model_dump() def test_get_plans_by_name(client: BlueapiClient, expected_plans: PlanResponse): @@ -337,11 +339,54 @@ 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.xfail() +@pytest.mark.parametrize( + "task", + [ + Task( + name="count", + params={ + "detectors": [ + "image_det", + "current_det", + ], + "num": 5, + }, + ), + pytest.param( + Task( + name="spec_scan", + params={ + "detectors": [ + "image_det", + "current_det", + ], + "spec": Line("x", 0.0, 10.0, 10) * Line("y", 5.0, 15.0, 20), + }, + ), + marks=pytest.mark.xfail( + reason="https://github.com/DiamondLightSource/blueapi/issues/782" + ), + ), + ], +) +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