Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies = [
"ophyd >= 1.10.5",
"ophyd-async >= 0.14.0",
"bluesky >= 1.14.6",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@62960e0e587bf86943ce1b581848fa131ef884d5",
"dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@mx_bluesky_1448_use_config_server",
]


Expand Down
2 changes: 1 addition & 1 deletion src/mx_bluesky/common/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DocDescriptorNames:

def _get_oav_config_json_path():
if TEST_MODE:
return "tests/test_data/test_OAVCentring.json"
return "OAVCentring.json"
elif BEAMLINE == "i03":
return f"/dls_sw/{BEAMLINE}/software/daq_configuration/json/OAVCentring_hyperion.json"
elif BEAMLINE == "aithre":
Expand Down
53 changes: 28 additions & 25 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import partial
from pathlib import Path
from types import ModuleType
from typing import Any
from typing import Any, TypedDict
from unittest.mock import AsyncMock, MagicMock, patch

import numpy
Expand Down Expand Up @@ -60,6 +60,7 @@
from dodal.devices.zocalo.zocalo_results import _NO_SAMPLE_ID
from dodal.log import LOGGER as DODAL_LOGGER
from dodal.log import set_up_all_logging_handlers
from dodal.testing import MockConfigServer
from dodal.utils import AnyDeviceFactory, collect_factories
from event_model.documents import Event, EventDescriptor, RunStart, RunStop
from ophyd.sim import NullStatus
Expand Down Expand Up @@ -218,8 +219,8 @@
MOCK_DAQ_CONFIG_PATH = "tests/test_data/test_daq_configuration"
mock_paths = [
("DAQ_CONFIGURATION_PATH", MOCK_DAQ_CONFIG_PATH),
("ZOOM_PARAMS_FILE", "tests/test_data/test_jCameraManZoomLevels.xml"),
("DISPLAY_CONFIG", f"{MOCK_DAQ_CONFIG_PATH}/display.configuration"),
("ZOOM_PARAMS_FILE", "jCameraManZoomLevels.xml"),
("DISPLAY_CONFIG", "display.configuration"),
]
mock_attributes_table = {
"i03": mock_paths,
Expand Down Expand Up @@ -788,13 +789,19 @@ async def beamsize(aperture_scatterguard: ApertureScatterguard):
return Beamsize(aperture_scatterguard, name="beamsize")


class ConfigFilesForTests(TypedDict):
zoom_params_file: str
oav_config_json: str
display_config: str


@pytest.fixture()
def test_config_files():
return {
"zoom_params_file": "tests/test_data/test_jCameraManZoomLevels.xml",
"oav_config_json": "tests/test_data/test_OAVCentring.json",
"display_config": "tests/test_data/test_display.configuration",
}
return ConfigFilesForTests(
zoom_params_file="jCameraManZoomLevels.xml",
oav_config_json="OAVCentring.json",
display_config="display.configuration",
)


@pytest.fixture()
Expand Down Expand Up @@ -1703,37 +1710,33 @@ def assert_images_pixelwise_equal(actual, expected):
)


def _fake_config_server_read(
filepath: str | Path,
desired_return_type: type[str] | type[dict] = str,
reset_cached_result=False,
):
filepath = Path(filepath)
# Minimal logic required for unit tests
with filepath.open("r") as f:
contents = f.read()
if desired_return_type is str:
return contents
elif desired_return_type is dict:
return json.loads(contents)


IMPLEMENTED_CONFIG_CLIENTS: list[Callable] = [
get_hyperion_config_client,
get_i04_config_client,
]


@pytest.fixture(autouse=True)
def mock_config_server():
def mock_mx_config_server():
# Don't actually talk to central service during unit tests, and reset caches between test

for client in IMPLEMENTED_CONFIG_CLIENTS:
client.cache_clear() # type: ignore - currently no option for "cachable" static type

with patch(
"mx_bluesky.common.external_interaction.config_server.MXConfigClient.get_file_contents",
side_effect=_fake_config_server_read,
side_effect=MockConfigServer().get_file_contents,
):
yield


@pytest.fixture(autouse=True)
def mock_config_server():
# Don't actually talk to central service during unit tests, and reset caches between test

with patch(
"daq_config_server.client.ConfigServer.get_file_contents",
side_effect=MockConfigServer().get_file_contents,
):
yield

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,14 +1124,6 @@ def grid_detect_for_snapshot_generation():


class TestGenerateSnapshot:
@pytest.fixture()
def test_config_files(self):
return {
"zoom_params_file": "tests/test_data/test_jCameraManZoomLevels.xml",
"oav_config_json": "tests/test_data/test_daq_configuration/OAVCentring_hyperion.json",
"display_config": "tests/test_data/test_daq_configuration/display.configuration",
}

@pytest.mark.system_test
def test_load_centre_collect_generate_rotation_snapshots(
self,
Expand Down
69 changes: 0 additions & 69 deletions tests/test_data/test_OAVCentring.json

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions tests/test_data/test_daq_configuration/display.configuration

This file was deleted.

42 changes: 0 additions & 42 deletions tests/test_data/test_display.configuration

This file was deleted.

Binary file modified tests/test_data/test_images/ins_15_33_expected_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/test_data/test_images/ins_15_33_expected_270.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/test_data/test_images/thau_1_91_expected_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/test_data/test_images/thau_1_91_expected_270.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 0 additions & 42 deletions tests/test_data/test_jCameraManZoomLevels.xml

This file was deleted.

12 changes: 5 additions & 7 deletions tests/unit_tests/beamlines/i04/test_thawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
thaw_and_murko_centre,
thaw_and_stream_to_redis,
)

DISPLAY_CONFIGURATION = "tests/test_data/test_display.configuration"
ZOOM_LEVELS_XML = "tests/test_data/test_jCameraManZoomLevels.xml"
from tests.conftest import ConfigFilesForTests


class MyError(Exception):
pass


@pytest.fixture
async def oav_full_screen() -> OAV:
oav_config = OAVConfig(ZOOM_LEVELS_XML)
async def oav_full_screen(test_config_files: ConfigFilesForTests) -> OAV:
oav_config = OAVConfig(test_config_files["zoom_params_file"])
async with init_devices(mock=True, connect=True):
oav = OAVBeamCentrePV(
"", config=oav_config, name="oav_full_screen", mjpeg_prefix="XTAL"
Expand All @@ -57,8 +55,8 @@ async def oav_full_screen() -> OAV:


@pytest.fixture
async def oav_roi() -> OAV:
oav_config = OAVConfig(ZOOM_LEVELS_XML)
async def oav_roi(test_config_files: ConfigFilesForTests) -> OAV:
oav_config = OAVConfig(test_config_files["zoom_params_file"])
async with init_devices(mock=True, connect=True):
oav = OAVBeamCentrePV("", config=oav_config, name="oav")
zoom_levels_list = ["1.0x", "2.0x", "5.0x"]
Expand Down
Loading
Loading