|
8 | 8 | from functools import partial |
9 | 9 | from pathlib import Path |
10 | 10 | from types import ModuleType |
11 | | -from typing import Any, TypeVar |
| 11 | +from typing import Any, TypedDict, TypeVar |
12 | 12 | from unittest.mock import MagicMock, patch |
13 | 13 |
|
14 | 14 | import bluesky.plan_stubs as bps |
|
116 | 116 | HyperionFlyScanXRayCentreComposite, |
117 | 117 | ) |
118 | 118 | from mx_bluesky.hyperion.parameters.gridscan import HyperionSpecifiedThreeDGridScan |
| 119 | +from tests.test_data.oav import ( |
| 120 | + TEST_DISPLAY_CONFIG, |
| 121 | + TEST_OAV_CENTRING_JSON, |
| 122 | + TEST_OAV_ZOOM_LEVELS, |
| 123 | +) |
| 124 | + |
| 125 | +TEST_BEAMLINE_PARAMETERS = "tests/test_data/test_beamline_parameters.txt" |
119 | 126 |
|
120 | 127 | pytest_plugins = ["tests.expeye_helpers"] |
121 | 128 |
|
|
223 | 230 | } |
224 | 231 | ] |
225 | 232 |
|
| 233 | +MOCK_DAQ_CONFIG_PATH = "tests/test_data/test_daq_configuration" |
| 234 | +mock_paths = [ |
| 235 | + ("DAQ_CONFIGURATION_PATH", MOCK_DAQ_CONFIG_PATH), |
| 236 | + ("ZOOM_PARAMS_FILE", TEST_OAV_ZOOM_LEVELS), |
| 237 | + ("DISPLAY_CONFIG", TEST_DISPLAY_CONFIG), |
| 238 | +] |
| 239 | + |
226 | 240 |
|
227 | 241 | @dataclass(frozen=True) |
228 | 242 | class SimConstants: |
@@ -364,7 +378,7 @@ def _pass_on_mock(value: float, wait: bool): |
364 | 378 |
|
365 | 379 | @pytest.fixture |
366 | 380 | def beamline_parameters(): |
367 | | - with Path("tests/test_data/test_beamline_parameters.txt").open("r") as f: |
| 381 | + with Path(TEST_BEAMLINE_PARAMETERS).open("r") as f: |
368 | 382 | contents = f.read() |
369 | 383 | return json.loads(contents) |
370 | 384 |
|
@@ -478,7 +492,9 @@ def synchrotron(): |
478 | 492 | @pytest.fixture |
479 | 493 | def oav(test_config_files): |
480 | 494 | parameters = OAVConfigBeamCentre( |
481 | | - test_config_files["zoom_params_file"], test_config_files["display_config"] |
| 495 | + test_config_files["zoom_params_file"], |
| 496 | + test_config_files["display_config"], |
| 497 | + ConfigClient(""), |
482 | 498 | ) |
483 | 499 | oav = i03.oav.build(mock=True, connect_immediately=True, params=parameters) |
484 | 500 |
|
@@ -562,8 +578,8 @@ def beamstop_phase1( |
562 | 578 | sim_run_engine: RunEngineSimulator, |
563 | 579 | ) -> Generator[Beamstop, Any, Any]: |
564 | 580 | with patch( |
565 | | - "dodal.beamlines.i03.get_beamline_parameters", |
566 | | - return_value=beamline_parameters, |
| 581 | + "dodal.beamlines.i03.BEAMLINE_PARAMETERS_PATH", |
| 582 | + TEST_BEAMLINE_PARAMETERS, |
567 | 583 | ): |
568 | 584 | beamstop = i03.beamstop.build(connect_immediately=True, mock=True) |
569 | 585 |
|
@@ -752,13 +768,19 @@ async def beamsize(aperture_scatterguard: ApertureScatterguard): |
752 | 768 | return Beamsize(aperture_scatterguard, name="beamsize") |
753 | 769 |
|
754 | 770 |
|
| 771 | +class ConfigFilesForTests(TypedDict): |
| 772 | + zoom_params_file: str |
| 773 | + oav_config_json: str |
| 774 | + display_config: str |
| 775 | + |
| 776 | + |
755 | 777 | @pytest.fixture() |
756 | 778 | def test_config_files(): |
757 | | - return { |
758 | | - "zoom_params_file": "tests/test_data/test_jCameraManZoomLevels.xml", |
759 | | - "oav_config_json": "tests/test_data/test_OAVCentring.json", |
760 | | - "display_config": "tests/test_data/test_display.configuration", |
761 | | - } |
| 779 | + return ConfigFilesForTests( |
| 780 | + zoom_params_file=TEST_OAV_ZOOM_LEVELS, |
| 781 | + oav_config_json=TEST_OAV_CENTRING_JSON, |
| 782 | + display_config=TEST_DISPLAY_CONFIG, |
| 783 | + ) |
762 | 784 |
|
763 | 785 |
|
764 | 786 | @pytest.fixture() |
|
0 commit comments