DiamondLightSource / DiamondLightSource/dodal
Add helper test function to check if plan using inject has a valid default device for a beamline
- Dominant language
- Python
- Stars
- 5
- Forks
- 13
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 10
Description
When creating a plan with a default device, you do this:
```Python
from dodal.common import inject
from dodal.devices import MyDevice
def my_plan(..., device_a: MyDevice = inject("device_a")):
device_a.do_thing(...)
```
This `inject` function works with `blueapi` and converts the `inject` to a device configured on the beamline. However, when writing a plan, how do we check a valid default device is valid for a plan on a beamline? When updating beamline configuration, how do we check a change doesn't break a plans default devices?
I propose we make a new testing function, something like
```Python
def assert_plan_has_valid_inject_devices_for_beamline(beamline: str: plan: Function) -> None:
beamline_devices, _ = make_all_devices(
f"dodal.beamlines.{beamline}", connect_immediately=True, mock=True
)
plan_inject_device_names = find_inject_args(plan)
# assert here that plan_inject_device_names exist in beamline_devices
```
Then plan repos can add this function to their tests to check that their plans and default devices are always in sync
## Acceptance Criteria
* Function is added to dodal.testing to check plan args using inject exists on beamline
Contributor guide
Assessment
This issue has not been assessed yet.