DiamondLightSource / DiamondLightSource/dodal
Dodal unit tests attempt to connect to real devices, `setup_context()` unexpected behaviour
- Dominant language
- Python
- Stars
- 5
- Forks
- 13
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 10
Description
Whilst addressing
* DiamondLightSource/dodal#846
It was discovered that `test_main_system::test_when_context_created_then_contains_expected_number_of_plans()` was taking > 15s to complete
This is because it is actually creating and attempting to connect to real devices, instead of mocked ones. It fails but the error message is caught and no error message is printed as the relevant logger is not enabled, and the test passes.
Ostensibly this test should test that the plans are created as expected. for this to work `setup_context()` needs to support a `mock` parameter that can get passed to the beamline device factories. It used to but this was removed in https://github.com/DiamondLightSource/hyperion/pull/1481 although this test never used it.
We should reinstate this override. The desired behaviour implied by 1481 does not happen (at least for ophyd_async) in any case since ophyd_async `ensure_connected()` always specifies the parameters to `device.connect()` explicitly which means that default implementation in device will always be overridden in production.
In addition, the `wait_for_connection` parameter is totally ignored as blueapi `with_dodal_module()` always invokes `utils.connect_devices()` unconditionally.
## Acceptance Criteria
* `setup_context()` is rewritten so that it no longer promises to do things that it doesn't actually do
* unit tests pass without delay
* Talk to @DominicOram to find out what the actual use case was for having mock devices on the beamline - do they still exist?
Contributor guide
Assessment
This issue has not been assessed yet.