File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -225,3 +225,26 @@ def test_get_file_contents_with_bad_force_parser_errors(
225225 DisplayConfig ,
226226 force_parser = DisplayConfig .from_contents ,
227227 )
228+
229+
230+ @patch ("daq_config_server.app.client.requests.get" )
231+ def test_reset_cache (
232+ mock_request : MagicMock ,
233+ ):
234+ mock_config = "Units eV mm\n 5700 5.4606\n #24500 7.2\n "
235+ mock_request .return_value = make_test_response (mock_config )
236+ server = ConfigClient ("url" )
237+ result = server .get_file_contents (
238+ test_path ,
239+ str ,
240+ )
241+ assert server ._cache .currsize == 1
242+ server .reset_cache ()
243+ assert server ._cache .currsize == 0
244+ new_mock_config = "Units eV mm\n 6800 5.4606\n #24500 7.2\n "
245+ mock_request .return_value = make_test_response (new_mock_config )
246+ new_result = server .get_file_contents (
247+ test_path ,
248+ str ,
249+ )
250+ assert result != new_result
Original file line number Diff line number Diff line change 1+ import pytest
2+ from pydantic import ValidationError
3+
4+ from daq_config_server .models .feature_settings .feature_settings import (
5+ BaseFeatureSettings ,
6+ FeatureSettingSources ,
7+ )
18from daq_config_server .models .feature_settings .hyperion_feature_settings import (
29 HyperionFeatureSettings ,
310)
@@ -33,3 +40,23 @@ def test_i04_feature_flags():
3340 )
3441 config = I04FeatureSettings .from_domain_properties (contents )
3542 assert config == expected
43+
44+
45+ def test_error_raised_when_feature_settings ():
46+ class BadFeatureSettingsSources (FeatureSettingSources ):
47+ USE_GPU_RESULTS = "gda.mx.hyperion.xrc.use_gpu_results"
48+ USE_ZEBRA_FOR_GRIDSCAN = "gda.mx.hyperion.use_panda_for_gridscans"
49+ SET_STUB_OFFSETS = "gda.mx.hyperion.do_stub_offsets"
50+
51+ class BadFeatureSettings (BaseFeatureSettings ):
52+ USE_GPU_RESULTS : bool = False
53+
54+ @staticmethod
55+ def feature_settings_sources ():
56+ return BadFeatureSettingsSources
57+
58+ with pytest .raises (ValidationError ):
59+ BadFeatureSettings .from_domain_properties ("" )
60+
61+ with pytest .raises (ValidationError ):
62+ BadFeatureSettings (USE_GPU_RESULTS = True )
You can’t perform that action at this time.
0 commit comments