Skip to content

Commit f6cde85

Browse files
committed
Small change
1 parent dfc12c0 commit f6cde85

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/daq_config_server/converters/_file_converter_map.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
undulator_energy_gap_lut,
1414
)
1515

16-
xmltodict.parse.__annotations__["return"] = dict[str, Any]
17-
1816
FILE_TO_CONVERTER_MAP: dict[str, Callable[[str], BaseModel | dict[str, Any]]] = { # type: ignore
1917
"/tests/test_data/test_good_lut.txt": undulator_energy_gap_lut, # For system tests # noqa
2018
"/dls_sw/i23/software/aithre/aithre_display.configuration": display_config_to_model,

tests/system_tests/test_client.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
33
from typing import Any, get_type_hints
4-
from unittest.mock import MagicMock
4+
from unittest.mock import MagicMock, patch
55

66
import pytest
77
import requests
@@ -151,8 +151,12 @@ def test_all_files_in_file_converter_map_can_be_converted_to_dict(server: Config
151151
def test_all_files_in_file_converter_map_can_be_converted_to_target_type(
152152
server: ConfigServer,
153153
):
154-
for filename, converter in file_converter_map.FILE_TO_CONVERTER_MAP.items():
155-
return_type = get_type_hints(converter)["return"]
156-
assert return_type is dict or issubclass(return_type, BaseModel)
157-
result = server.get_file_contents(filename, return_type)
158-
assert isinstance(result, return_type)
154+
with patch(
155+
"daq_config_server.converters._file_converter_map.xmltodict.parse.__annotations__",
156+
{"return": dict}, # Force a return type for xmltodict.parse()
157+
):
158+
for filename, converter in file_converter_map.FILE_TO_CONVERTER_MAP.items():
159+
return_type = get_type_hints(converter)["return"]
160+
assert return_type is dict or issubclass(return_type, BaseModel)
161+
result = server.get_file_contents(filename, return_type)
162+
assert isinstance(result, return_type)

0 commit comments

Comments
 (0)