From b82e4c47d869993d98771623c3b636a9870d8269 Mon Sep 17 00:00:00 2001 From: vux62295 Date: Fri, 5 Jun 2026 10:35:00 +0100 Subject: [PATCH 1/6] Added test cases for new Eurotherm records --- common_tests/eurotherm.py | 28 ++++++++++++++++++++++------ tests/eurotherm_eibisynch.py | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/common_tests/eurotherm.py b/common_tests/eurotherm.py index 1da32013..76fa81a7 100644 --- a/common_tests/eurotherm.py +++ b/common_tests/eurotherm.py @@ -241,20 +241,20 @@ def test_GIVEN_temperature_set_WHEN_changing_calibration_files_THEN_temperature_ self._set_setpoint_and_current_temperature(temperature) self._assert_using_mock_table_location() with use_calibration_file(self.ca, "None.txt", prefix="A01:"): - self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance) - self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance) + self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance, timeout=30) + self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30) with use_calibration_file(self.ca, "C.txt", prefix="A01:"): self.ca.assert_that_pv_is_number( - "A01:TEMP", temperature_calibrated, tolerance=tolerance + "A01:TEMP", temperature_calibrated, tolerance=tolerance, timeout=30 ) self.ca.assert_that_pv_is_number( - "A01:TEMP:SP:RBV", temperature_calibrated, tolerance=tolerance + "A01:TEMP:SP:RBV", temperature_calibrated, tolerance=tolerance, timeout=30 ) with use_calibration_file(self.ca, "None.txt", prefix="A01:"): - self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance) - self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance) + self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance, timeout=30) + self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30) def _assert_units(self, units): # High timeouts because setting units does not cause processing - wait for normal scan loop to come around. @@ -418,3 +418,19 @@ def test_WHEN_high_limit_set_via_backdoor_THEN_high_lim_updates(self, _, val): def test_WHEN_low_limit_set_via_backdoor_THEN_low_lim_updates(self, _, val): self._lewis.backdoor_run_function_on_device("set_low_lim", [SENSORS[0], val]) self.ca.assert_that_pv_is_number("A01:LOWLIM", val, tolerance=0.05, timeout=15) + + @parameterized.expand(parameterized_list(TEST_VALUES)) + @skip_if_recsim("Backdoor not available in recsim") + def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val): + self.ca.set_pv_value("A01:AUTOMAN", 1) + self.ca.assert_that_pv_is("A01:AUTOMAN", "ON") + self.ca.set_pv_value("A01:AUTOMAN", 0) + self.ca.assert_that_pv_is("A01:AUTOMAN", "OFF") + + @parameterized.expand(parameterized_list(TEST_VALUES)) + @skip_if_recsim("Backdoor not available in recsim") + def test_WHEN_sensorbreak_set_via_backdoor_THEN_shows_updated_value(self, _, val): + self.ca.set_pv_value("A01:SNBRKPST", 1) + self.ca.assert_that_pv_is("A01:SNBRKPST", "ON") + self.ca.set_pv_value("A01:SNBRKPST", 0) + self.ca.assert_that_pv_is("A01:SNBRKPST", "OFF") \ No newline at end of file diff --git a/tests/eurotherm_eibisynch.py b/tests/eurotherm_eibisynch.py index ab1fb334..b2f1b5ed 100644 --- a/tests/eurotherm_eibisynch.py +++ b/tests/eurotherm_eibisynch.py @@ -122,7 +122,7 @@ def test_GIVEN_sim_delay_WHEN_temp_read_from_many_sensors_THEN_all_reads_correct self._lewis.backdoor_run_function_on_device( "set_current_temperature", [sensor, float(temp)] ) - self.ca.assert_that_pv_is(f"{pv_sensor}:RBV", float(temp)) + self.ca.assert_that_pv_is(f"{pv_sensor}:RBV", float(temp), timeout=30.0) self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0]) From feaeee91859c1bfa25f2fe111024c52d2d8f64b4 Mon Sep 17 00:00:00 2001 From: vux62295 Date: Fri, 5 Jun 2026 10:48:54 +0100 Subject: [PATCH 2/6] Fixed ruff --- common_tests/eurotherm.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/common_tests/eurotherm.py b/common_tests/eurotherm.py index 76fa81a7..b58451f3 100644 --- a/common_tests/eurotherm.py +++ b/common_tests/eurotherm.py @@ -241,8 +241,12 @@ def test_GIVEN_temperature_set_WHEN_changing_calibration_files_THEN_temperature_ self._set_setpoint_and_current_temperature(temperature) self._assert_using_mock_table_location() with use_calibration_file(self.ca, "None.txt", prefix="A01:"): - self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance, timeout=30) - self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30) + self.ca.assert_that_pv_is_number( + "A01:TEMP", temperature, tolerance=tolerance, timeout=30 + ) + self.ca.assert_that_pv_is_number( + "A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30 + ) with use_calibration_file(self.ca, "C.txt", prefix="A01:"): self.ca.assert_that_pv_is_number( @@ -253,8 +257,12 @@ def test_GIVEN_temperature_set_WHEN_changing_calibration_files_THEN_temperature_ ) with use_calibration_file(self.ca, "None.txt", prefix="A01:"): - self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance, timeout=30) - self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30) + self.ca.assert_that_pv_is_number( + "A01:TEMP", temperature, tolerance=tolerance, timeout=30 + ) + self.ca.assert_that_pv_is_number( + "A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30 + ) def _assert_units(self, units): # High timeouts because setting units does not cause processing - wait for normal scan loop to come around. @@ -418,7 +426,7 @@ def test_WHEN_high_limit_set_via_backdoor_THEN_high_lim_updates(self, _, val): def test_WHEN_low_limit_set_via_backdoor_THEN_low_lim_updates(self, _, val): self._lewis.backdoor_run_function_on_device("set_low_lim", [SENSORS[0], val]) self.ca.assert_that_pv_is_number("A01:LOWLIM", val, tolerance=0.05, timeout=15) - + @parameterized.expand(parameterized_list(TEST_VALUES)) @skip_if_recsim("Backdoor not available in recsim") def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val): @@ -433,4 +441,4 @@ def test_WHEN_sensorbreak_set_via_backdoor_THEN_shows_updated_value(self, _, val self.ca.set_pv_value("A01:SNBRKPST", 1) self.ca.assert_that_pv_is("A01:SNBRKPST", "ON") self.ca.set_pv_value("A01:SNBRKPST", 0) - self.ca.assert_that_pv_is("A01:SNBRKPST", "OFF") \ No newline at end of file + self.ca.assert_that_pv_is("A01:SNBRKPST", "OFF") From a2893647f93830ba20e964e6397ac8ce5a9f5699 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Sat, 6 Jun 2026 23:23:27 +0100 Subject: [PATCH 3/6] Reduce sim delay time used on test With additional PVs added the previous delay caused too big a backlog causing this and other tests to fail --- tests/eurotherm_eibisynch.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/eurotherm_eibisynch.py b/tests/eurotherm_eibisynch.py index b2f1b5ed..6f6232e0 100644 --- a/tests/eurotherm_eibisynch.py +++ b/tests/eurotherm_eibisynch.py @@ -44,6 +44,7 @@ class EurothermTests(EurothermBaseTests, unittest.TestCase): def setUp(self): super(EurothermTests, self).setUp() self._lewis.backdoor_run_function_on_device("set_scaling", ["01", 1.0]) + self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0]) self._lewis: LewisLauncher def get_device(self): @@ -113,7 +114,7 @@ def test_GIVEN_None_txt_calib_file_WHEN_changed_to_C006_calib_file_THEN_the_cali self.ca.assert_that_pv_is("A01:TEMP:RANGE:UNDER.B", c006_calibration_file_min) def test_GIVEN_sim_delay_WHEN_temp_read_from_many_sensors_THEN_all_reads_correct(self) -> None: - self._lewis.backdoor_run_function_on_device("set_delay_time", [(300 / 1000)]) + self._lewis.backdoor_run_function_on_device("set_delay_time", [(200 / 1000)]) for id in range(1, 7): pv_sensor = f"A{id:02}" sensor = f"{id:02}" @@ -124,18 +125,14 @@ def test_GIVEN_sim_delay_WHEN_temp_read_from_many_sensors_THEN_all_reads_correct ) self.ca.assert_that_pv_is(f"{pv_sensor}:RBV", float(temp), timeout=30.0) - self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0]) - def test_GIVEN_sim_delay_WHEN_temp_set_on_multiple_sensors_THEN_all_reads_correct(self) -> None: - self._lewis.backdoor_run_function_on_device("set_delay_time", [(300 / 1000)]) + self._lewis.backdoor_run_function_on_device("set_delay_time", [(200 / 1000)]) for id in range(1, 7): sensor = f"A{id:02}" for temp in range(1, 3): self._set_setpoint_and_current_temperature(float(temp), sensor=sensor) self.ca.assert_that_pv_is(f"{sensor}:RBV", float(temp), timeout=30.0) - self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0]) - def test_GIVEN_many_sensors_WHEN_one_sensor_disconnect_THEN_other_sensors_read_ok(self) -> None: # Ensure that A02 is connected self._lewis.backdoor_run_function_on_device("set_connected", ["02", True]) From 350015f034da3aa5a86e6f8abc54909797d446b7 Mon Sep 17 00:00:00 2001 From: vux62295 Date: Sun, 7 Jun 2026 22:01:02 +0100 Subject: [PATCH 4/6] Corrected the new test cases --- common_tests/eurotherm.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/common_tests/eurotherm.py b/common_tests/eurotherm.py index b58451f3..2a0d842f 100644 --- a/common_tests/eurotherm.py +++ b/common_tests/eurotherm.py @@ -27,6 +27,8 @@ PV_SENSORS = ["A01", "A02", "A03", "A04", "A05", "A06"] +BINARY_VALUES = [0, 1] + # This class is only valid for classes which also derive from unittest.TestCase, # and we can't derive from unittest.TestCase at runtime, because @@ -427,18 +429,19 @@ def test_WHEN_low_limit_set_via_backdoor_THEN_low_lim_updates(self, _, val): self._lewis.backdoor_run_function_on_device("set_low_lim", [SENSORS[0], val]) self.ca.assert_that_pv_is_number("A01:LOWLIM", val, tolerance=0.05, timeout=15) - @parameterized.expand(parameterized_list(TEST_VALUES)) + @parameterized.expand(parameterized_list(BINARY_VALUES)) @skip_if_recsim("Backdoor not available in recsim") def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val): - self.ca.set_pv_value("A01:AUTOMAN", 1) - self.ca.assert_that_pv_is("A01:AUTOMAN", "ON") - self.ca.set_pv_value("A01:AUTOMAN", 0) - self.ca.assert_that_pv_is("A01:AUTOMAN", "OFF") + expected_value = {0: "OFF", 1: "ON"}[val] - @parameterized.expand(parameterized_list(TEST_VALUES)) + self.ca.set_pv_value("A01:AUTOMAN:SP", val) + self.ca.assert_that_pv_is("A01:AUTOMAN", expected_value) + + @parameterized.expand(parameterized_list(BINARY_VALUES)) @skip_if_recsim("Backdoor not available in recsim") def test_WHEN_sensorbreak_set_via_backdoor_THEN_shows_updated_value(self, _, val): - self.ca.set_pv_value("A01:SNBRKPST", 1) - self.ca.assert_that_pv_is("A01:SNBRKPST", "ON") - self.ca.set_pv_value("A01:SNBRKPST", 0) - self.ca.assert_that_pv_is("A01:SNBRKPST", "OFF") + expected_value = {0: "OFF", 1: "ON"}[val] + + self._lewis.backdoor_run_function_on_device("set_snbrkpst", [SENSORS[0], val]) + self.ca.assert_that_pv_is("A01:SNBRKPST", expected_value) + From ffca81d40f0a444284816f8292d4f2f9e2690ea4 Mon Sep 17 00:00:00 2001 From: vux62295 Date: Sun, 7 Jun 2026 22:06:55 +0100 Subject: [PATCH 5/6] Reformatted --- common_tests/eurotherm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common_tests/eurotherm.py b/common_tests/eurotherm.py index 2a0d842f..c47fc637 100644 --- a/common_tests/eurotherm.py +++ b/common_tests/eurotherm.py @@ -441,7 +441,6 @@ def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val): @skip_if_recsim("Backdoor not available in recsim") def test_WHEN_sensorbreak_set_via_backdoor_THEN_shows_updated_value(self, _, val): expected_value = {0: "OFF", 1: "ON"}[val] - + self._lewis.backdoor_run_function_on_device("set_snbrkpst", [SENSORS[0], val]) self.ca.assert_that_pv_is("A01:SNBRKPST", expected_value) - From 456c6b826455975fe316ca6994c7dbe94fdb68b4 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Mon, 8 Jun 2026 18:29:08 +0100 Subject: [PATCH 6/6] Remove skip_of_recsim from automan test --- common_tests/eurotherm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/common_tests/eurotherm.py b/common_tests/eurotherm.py index c47fc637..c53bbe61 100644 --- a/common_tests/eurotherm.py +++ b/common_tests/eurotherm.py @@ -430,7 +430,6 @@ def test_WHEN_low_limit_set_via_backdoor_THEN_low_lim_updates(self, _, val): self.ca.assert_that_pv_is_number("A01:LOWLIM", val, tolerance=0.05, timeout=15) @parameterized.expand(parameterized_list(BINARY_VALUES)) - @skip_if_recsim("Backdoor not available in recsim") def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val): expected_value = {0: "OFF", 1: "ON"}[val]