From dad5500447f876c5aebfdb49d8a1cc4593561ce5 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 5 Aug 2024 13:50:30 +0100 Subject: [PATCH 1/3] Run safe ruff fixes --- system_tests/lewis_emulators/PearlPC/__init__.py | 2 +- system_tests/lewis_emulators/PearlPC/device.py | 7 +++---- .../lewis_emulators/PearlPC/interfaces/stream_interface.py | 6 +++--- system_tests/tests/pearlpc.py | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/system_tests/lewis_emulators/PearlPC/__init__.py b/system_tests/lewis_emulators/PearlPC/__init__.py index 7cd648e..e2098fb 100644 --- a/system_tests/lewis_emulators/PearlPC/__init__.py +++ b/system_tests/lewis_emulators/PearlPC/__init__.py @@ -1,5 +1,5 @@ -from .device import SimulatedPearlPC from ..lewis_versions import LEWIS_LATEST +from .device import SimulatedPearlPC framework_version = LEWIS_LATEST __all__ = ['SimulatedPearlPC'] diff --git a/system_tests/lewis_emulators/PearlPC/device.py b/system_tests/lewis_emulators/PearlPC/device.py index 7c3fe21..6766151 100644 --- a/system_tests/lewis_emulators/PearlPC/device.py +++ b/system_tests/lewis_emulators/PearlPC/device.py @@ -1,9 +1,8 @@ -import time -import threading +from collections import OrderedDict + from lewis.devices import StateMachineDevice -from lewis.core import approaches + from .states import DefaultState -from collections import OrderedDict class SimulatedPearlPC(StateMachineDevice): diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index f8cbf7c..2598b88 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -1,6 +1,6 @@ -from lewis.adapters.stream import StreamInterface, Cmd -from lewis.utils.command_builder import CmdBuilder +from lewis.adapters.stream import StreamInterface from lewis.core.logging import has_log +from lewis.utils.command_builder import CmdBuilder from lewis.utils.replies import conditional_reply @@ -116,7 +116,7 @@ def reset(self): Reset to fully open pistons """ if self._device.get_pressure() < 100: - print(f"starting reset") + print("starting reset") self._device.reset() # set phase to resetting, this starts reset else: print("ERROR: cannot reset as pressure too high") diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 19d53ea..42eeb57 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -1,11 +1,11 @@ import itertools import unittest -from utils.test_modes import TestModes +from parameterized import parameterized from utils.channel_access import ChannelAccess from utils.ioc_launcher import get_default_ioc_dir +from utils.test_modes import TestModes from utils.testing import get_running_lewis_and_ioc, parameterized_list -from parameterized import parameterized # Device prefix DEVICE_A_PREFIX = "PEARLPC_01" From ca3635948d7c51c269d2b4ec00507a39e9822a10 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 5 Aug 2024 13:50:56 +0100 Subject: [PATCH 2/3] Run ruff format --- .../lewis_emulators/PearlPC/__init__.py | 2 +- .../lewis_emulators/PearlPC/device.py | 37 +++--- .../PearlPC/interfaces/__init__.py | 2 +- .../PearlPC/interfaces/stream_interface.py | 120 +++++++++++------- .../lewis_emulators/PearlPC/states.py | 2 +- system_tests/tests/pearlpc.py | 51 +++++--- 6 files changed, 122 insertions(+), 92 deletions(-) diff --git a/system_tests/lewis_emulators/PearlPC/__init__.py b/system_tests/lewis_emulators/PearlPC/__init__.py index e2098fb..abe3cc3 100644 --- a/system_tests/lewis_emulators/PearlPC/__init__.py +++ b/system_tests/lewis_emulators/PearlPC/__init__.py @@ -2,4 +2,4 @@ from .device import SimulatedPearlPC framework_version = LEWIS_LATEST -__all__ = ['SimulatedPearlPC'] +__all__ = ["SimulatedPearlPC"] diff --git a/system_tests/lewis_emulators/PearlPC/device.py b/system_tests/lewis_emulators/PearlPC/device.py index 6766151..9cd9738 100644 --- a/system_tests/lewis_emulators/PearlPC/device.py +++ b/system_tests/lewis_emulators/PearlPC/device.py @@ -6,7 +6,6 @@ class SimulatedPearlPC(StateMachineDevice): - def _initialize_data(self, status_dictionary=None): if status_dictionary is None: status_dictionary = {} @@ -28,11 +27,11 @@ def add_to_dict(self, value_id: str, unvalidated_value: object): def _get_state_handlers(self): return { - 'default': DefaultState(), + "default": DefaultState(), } def _get_initial_state(self): - return 'default' + return "default" def _get_transition_handlers(self): return OrderedDict([]) @@ -40,25 +39,25 @@ def _get_transition_handlers(self): def re_initialise(self): self.connected = True - self.initial_id_prefix = 1111 # 4 digits - self.secondary_id_prefix = 1111 # 4 digits + self.initial_id_prefix = 1111 # 4 digits + self.secondary_id_prefix = 1111 # 4 digits self.em_stop_status = 0 # Bool [0-1] self.run_bit = 0 # Bool [0-1] - self.reset_value = 0 # [0-4] + self.reset_value = 0 # [0-4] self.piston_reset_phase = 0 self.stop_bit = 0 # Bool [0-1] self.busy_bit = 0 # Bool [0-1] self.go_status = 0 - self.am_mode = 1 # auto mode (run from host) rather than manual + self.am_mode = 1 # auto mode (run from host) rather than manual self.loop_mode = 0 # Bool [0-1] self.seal_fail_value = 0 - self.seal_fail_status = 0 # set to 1 if sudden pressure drop more than seal_fail_value + self.seal_fail_status = 0 # set to 1 if sudden pressure drop more than seal_fail_value self.last_error_code = 0 self.pressure_rate = 0 self.min_value_pre_servoing = 0 self.setpoint_value = 0 self.max_value_pre_servoing = 0 - self.inputs = 0 # a 9 digit number like 111111001 showing input status + self.inputs = 0 # a 9 digit number like 111111001 showing input status self.cell_pressure = 0 self.pump_pressure = 0 self.transducer_difference_threshold = 2 @@ -74,7 +73,7 @@ def re_initialise(self): self.run_requested = 0 self.stop_requested = 0 self.reset_requested = 0 - self.ramping = 0 # ramping to setpoint as opposed to closed loop stabilisation? + self.ramping = 0 # ramping to setpoint as opposed to closed loop stabilisation? def get_pressure(self): value = 0.0 @@ -95,13 +94,13 @@ def get_pressure(self): def stop(self): self.stop_requested = 1 - + def reset(self): self.reset_requested = 1 - + def run(self): self.run_requested = 1 - + def poller(self): self.inputs = int("011110000") + int("000000001") * self.am_mode if self.reset_requested: @@ -134,7 +133,7 @@ def poller(self): self.last_error_code = 12 self.stop_requested = 1 -# need to do closed loop better + # need to do closed loop better def running(self): pressure = self.get_pressure() if self.ramping == 1: @@ -148,12 +147,12 @@ def running(self): incr = self.pressure_rate if pressure < self.setpoint_value: self.pump_pressure = self.pump_pressure + incr - self.cell_pressure = self.pump_pressure # for simplicity + self.cell_pressure = self.pump_pressure # for simplicity else: self.pump_pressure = self.pump_pressure - incr - self.cell_pressure = self.pump_pressure # for simplicity - - # if self.loop_mode == 1: maintain between min_value_pre_servoing and max_value_pre_servoing + self.cell_pressure = self.pump_pressure # for simplicity + + # if self.loop_mode == 1: maintain between min_value_pre_servoing and max_value_pre_servoing if abs(self.cell_pressure - self.pump_pressure) > self.transducer_difference_threshold: self.last_error_code = 10 @@ -217,7 +216,7 @@ def set_sf_status(self, sf_status: int): print(f"Received seal fail bit {sf_status}") self.seal_fail_status = sf_status self.add_to_dict(value_id="sf_status", unvalidated_value=self.seal_fail_status) - + def set_go(self, go_status: int): """ Set GO status to to 1 if system was initiated by host. diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py b/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py index c164a27..a582a1b 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/__init__.py @@ -1,3 +1,3 @@ from .stream_interface import PearlPCStreamInterface -__all__ = ['PearlPCStreamInterface'] +__all__ = ["PearlPCStreamInterface"] diff --git a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py index 2598b88..8d85419 100644 --- a/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py +++ b/system_tests/lewis_emulators/PearlPC/interfaces/stream_interface.py @@ -21,21 +21,33 @@ class PearlPCStreamInterface(StreamInterface): CmdBuilder("set_mn").escape("mn").arg("[0-9]{4}", argument_mapping=int).eos().build(), CmdBuilder("set_sp").escape("sp").arg("[0-9]{4}", argument_mapping=int).eos().build(), CmdBuilder("set_mx").escape("mx").arg("[0-9]{4}", argument_mapping=int).eos().build(), - CmdBuilder("reset").escape("reset").eos().build(), - CmdBuilder("run").escape("run").eos().build(), - CmdBuilder("stop").escape("stop").eos().build(), - CmdBuilder("set_t").escape("t").arg("[1-2]0[1-3][0-9]{2}0[1-3]").eos().build(), + CmdBuilder("reset").escape("reset").eos().build(), + CmdBuilder("run").escape("run").eos().build(), + CmdBuilder("stop").escape("stop").eos().build(), + CmdBuilder("set_t").escape("t").arg("[1-2]0[1-3][0-9]{2}0[1-3]").eos().build(), CmdBuilder("set_th").escape("th").arg("[0-9]{4}", argument_mapping=int).eos().build(), - CmdBuilder("transducer_reset").escape("tr").eos().build(), + CmdBuilder("transducer_reset").escape("tr").eos().build(), CmdBuilder("set_algorithm").escape("a").arg("[a12hlw][0-9]{0,2}").eos().build(), CmdBuilder("get_dt").escape("dt").eos().build(), - CmdBuilder("set_user_stop_limit").escape("ul").arg("[0-9]{4}", argument_mapping=int).eos().build(), + CmdBuilder("set_user_stop_limit") + .escape("ul") + .arg("[0-9]{4}", argument_mapping=int) + .eos() + .build(), CmdBuilder("show_limits").escape("ls").eos().build(), CmdBuilder("get_memory").escape("vr").arg("[0-9]{4}", argument_mapping=int).eos().build(), CmdBuilder("set_pos_lim").escape("d+").arg("[0-9]{4}", argument_mapping=int).eos().build(), CmdBuilder("set_neg_lim").escape("d-").arg("[0-9]{4}", argument_mapping=int).eos().build(), - CmdBuilder("set_pos_offset").escape("o+").arg("[0-9]{1}", argument_mapping=int).eos().build(), - CmdBuilder("set_neg_offset").escape("o-").arg("[0-9]{1}", argument_mapping=int).eos().build(), + CmdBuilder("set_pos_offset") + .escape("o+") + .arg("[0-9]{1}", argument_mapping=int) + .eos() + .build(), + CmdBuilder("set_neg_offset") + .escape("o-") + .arg("[0-9]{1}", argument_mapping=int) + .eos() + .build(), } in_terminator = "\r" @@ -51,25 +63,27 @@ def get_st(self): @return: (str) A formatted string containing all set device parameters describing current device status. """ self._device.poller() - return f"Status Report{self.out_terminator}" \ - f"Em Ru Re St By Go AM sl sf Er ra mn sp mx Press Inputs{self.out_terminator}" \ - f"{self._device.em_stop_status} " \ - f"{self._device.run_bit} " \ - f"{self._device.reset_value} " \ - f"{self._device.stop_bit} " \ - f"{self._device.busy_bit} " \ - f"{self._device.go_status} " \ - f"{self._device.am_mode} " \ - f"{self._device.loop_mode} " \ - f"{self._device.seal_fail_status} " \ - f"{self._device.last_error_code} " \ - f"{self._device.pressure_rate} " \ - f"{self._device.min_value_pre_servoing} " \ - f"{self._device.setpoint_value} " \ - f"{self._device.max_value_pre_servoing} " \ - f"{self._device.get_pressure()} " \ - f"{self._device.inputs:09d}{self.out_terminator}" \ - f"OK" + return ( + f"Status Report{self.out_terminator}" + f"Em Ru Re St By Go AM sl sf Er ra mn sp mx Press Inputs{self.out_terminator}" + f"{self._device.em_stop_status} " + f"{self._device.run_bit} " + f"{self._device.reset_value} " + f"{self._device.stop_bit} " + f"{self._device.busy_bit} " + f"{self._device.go_status} " + f"{self._device.am_mode} " + f"{self._device.loop_mode} " + f"{self._device.seal_fail_status} " + f"{self._device.last_error_code} " + f"{self._device.pressure_rate} " + f"{self._device.min_value_pre_servoing} " + f"{self._device.setpoint_value} " + f"{self._device.max_value_pre_servoing} " + f"{self._device.get_pressure()} " + f"{self._device.inputs:09d}{self.out_terminator}" + f"OK" + ) @conditional_reply("connected") def get_id_prefix(self): @@ -77,7 +91,9 @@ def get_id_prefix(self): Returns ID prefixes (first 2 numbers selectable by the user formatted as: " ") @return: (str) formatted string returning ID prefixes set by default or by user. """ - print(f"ID prefix set to: {self._device.initial_id_prefix} {self._device.secondary_id_prefix}") + print( + f"ID prefix set to: {self._device.initial_id_prefix} {self._device.secondary_id_prefix}" + ) return f"{self._device.initial_id_prefix:04d} {self._device.secondary_id_prefix:04d} ISIS PEARL pressure intensifier V2.3" @conditional_reply("connected") @@ -88,7 +104,7 @@ def set_si(self, id_prefix: int): @param id_prefix: (int) Prefix to ID for a unit - range [0000-9999] """ print(f"SI prefix value received: {id_prefix}") - if (id_prefix < 0 or id_prefix > 9999): + if id_prefix < 0 or id_prefix > 9999: print("ERROR: invalid si value") self._device.initial_id_prefix = id_prefix @@ -104,7 +120,7 @@ def set_sd(self, secondary_id_prefix: int): @param secondary_id_prefix: (int) Prefix to ID for a unit - range [0000-9999] """ print(f"SD prefix value received: {secondary_id_prefix}") - if (secondary_id_prefix < 0 or secondary_id_prefix > 9999): + if secondary_id_prefix < 0 or secondary_id_prefix > 9999: print("ERROR: invalid sd value") self._device.secondary_id_prefix = secondary_id_prefix self._device.add_to_dict(value_id="sd", unvalidated_value=self._device.secondary_id_prefix) @@ -117,7 +133,7 @@ def reset(self): """ if self._device.get_pressure() < 100: print("starting reset") - self._device.reset() # set phase to resetting, this starts reset + self._device.reset() # set phase to resetting, this starts reset else: print("ERROR: cannot reset as pressure too high") self._device.last_error_code = 1 @@ -130,12 +146,12 @@ def set_sloop(self, sloop: int): 0 = open loop mode 1 = close loop mode Open loop mode ramps to pressure in control system and then stop until anther command is sent. - Close loop mode will ramp to setpoint pressure value and remain active monitoring delivered pressure, + Close loop mode will ramp to setpoint pressure value and remain active monitoring delivered pressure, acting on mn and mx pressure values. @param sloop: (int) integer value setting system to open or closed loop - range [0-1] """ print(f"sloop value recieved: {sloop}") - if (sloop < 0 or sloop > 1): + if sloop < 0 or sloop > 1: print("ERROR: invalid sloop") self._device.loop_mode = sloop self._device.add_to_dict(value_id="sloop", unvalidated_value=self._device.loop_mode) @@ -149,8 +165,8 @@ def set_sf(self, seal_fail_value: int): @param seal_fail_value: (int) Seal Fail Mode Trigger Value - range [0001-0999] """ print(f"Seal Fail mode trigger value received: {seal_fail_value}") - if (seal_fail_value < 1 or seal_fail_value > 999): - print("ERROR: invalid seal fail value") + if seal_fail_value < 1 or seal_fail_value > 999: + print("ERROR: invalid seal fail value") self._device.seal_fail_value = seal_fail_value self._device.add_to_dict(value_id="sf", unvalidated_value=self._device.seal_fail_value) return "" @@ -160,7 +176,7 @@ def error_reset(self): """ reset the last error code execpt for code 8 (seal fail) """ - if (self._device.last_error_code != 8): + if self._device.last_error_code != 8: self._device.last_error_code = 0 print(f"Resetting last error code: {self._device.last_error_code}") else: @@ -176,11 +192,11 @@ def set_ra(self, pressure_rate: int): @param pressure_rate: (int) Pressure rate within range [0001-0040] """ print(f"Pressure Rate Received: {pressure_rate}") - if (pressure_rate < 0 or pressure_rate > 40): + if pressure_rate < 0 or pressure_rate > 40: print("ERROR: invalid pressure rate") - if (pressure_rate == 0): - self._device.pressure_rate = 10 # maximum slew rate of the motor? - else: + if pressure_rate == 0: + self._device.pressure_rate = 10 # maximum slew rate of the motor? + else: self._device.pressure_rate = pressure_rate self._device.add_to_dict(value_id="ra", unvalidated_value=self._device.pressure_rate) return "" @@ -192,11 +208,13 @@ def set_mn(self, min_measured: int): This will only be acted upon in closed loop mode. @param min_measured: (int) minimum pressure value before re-servoing - range [0001-9999] """ - if (min_measured < 1 or min_measured > 9999): + if min_measured < 1 or min_measured > 9999: print("ERROR: invalid min measured") print(f"Minimum value before re-servoing received: {min_measured}") self._device.min_value_pre_servoing = min_measured - self._device.add_to_dict(value_id="mn", unvalidated_value=self._device.min_value_pre_servoing) + self._device.add_to_dict( + value_id="mn", unvalidated_value=self._device.min_value_pre_servoing + ) return "" @conditional_reply("connected") @@ -208,7 +226,7 @@ def set_sp(self, setpoint: int): @param setpoint: (int) Set Point trigger value - range [0001-1000] """ print(f"Setpoint value received: {setpoint}") - if (setpoint < 1 or setpoint > 1000): + if setpoint < 1 or setpoint > 1000: print("ERROR: invalid setpoint") self._device.setpoint_value = setpoint self._device.add_to_dict(value_id="sp", unvalidated_value=self._device.setpoint_value) @@ -220,14 +238,16 @@ def set_mx(self, max_measured: int): set the maximum measured value before re-servoing @param max_measured: (integer) maximum measured value before re-servoing - range [0001-9999] """ - if (max_measured < 1 or max_measured > 9999): + if max_measured < 1 or max_measured > 9999: print("ERROR: invalid max measured") print(f"Maximum measured value before re-servoing received: {max_measured}") self._device.max_value_pre_servoing = max_measured - self._device.add_to_dict(value_id="mx", unvalidated_value=self._device.max_value_pre_servoing) + self._device.add_to_dict( + value_id="mx", unvalidated_value=self._device.max_value_pre_servoing + ) return "" - def handle_error(self, request:object, error:object): + def handle_error(self, request: object, error: object): """ Return any errors which have occurred when sending requests to device. @return: (str) Formatted error message @@ -287,9 +307,11 @@ def set_user_stop_limit(self, value: int): @conditional_reply("connected") def show_limits(self): print("show_limits") - return f"User +Change +Offset -Change -Offset{self.out_terminator}" \ - f"{self._device.user_stop_limit} {self._device.dir_plus} {self._device.offset_plus} {self._device.dir_minus} {self._device.offset_minus}{self.out_terminator}" \ - f"OK" + return ( + f"User +Change +Offset -Change -Offset{self.out_terminator}" + f"{self._device.user_stop_limit} {self._device.dir_plus} {self._device.offset_plus} {self._device.dir_minus} {self._device.offset_minus}{self.out_terminator}" + f"OK" + ) @conditional_reply("connected") def get_memory(self, address: int): diff --git a/system_tests/lewis_emulators/PearlPC/states.py b/system_tests/lewis_emulators/PearlPC/states.py index fc1a11d..e4ca48e 100644 --- a/system_tests/lewis_emulators/PearlPC/states.py +++ b/system_tests/lewis_emulators/PearlPC/states.py @@ -2,4 +2,4 @@ class DefaultState(State): - pass \ No newline at end of file + pass diff --git a/system_tests/tests/pearlpc.py b/system_tests/tests/pearlpc.py index 42eeb57..e4d9e81 100644 --- a/system_tests/tests/pearlpc.py +++ b/system_tests/tests/pearlpc.py @@ -67,6 +67,7 @@ (19, "MONITOR process has stopped"), ] + class PEARLPCTests(unittest.TestCase): """ General Unit tests for the PEARLPC_01. @@ -79,29 +80,34 @@ def setUp(self): self.default_id_prefix = 1111 self.low_pressure = 50 self.lewis, self.ioc = get_running_lewis_and_ioc(DEVICE_A_PREFIX, DEVICE_A_PREFIX) - self.ca = ChannelAccess(default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX) + self.ca = ChannelAccess( + default_timeout=20, default_wait_time=0.0, device_prefix=DEVICE_A_PREFIX + ) self.lewis.backdoor_run_function_on_device("re_initialise") self.ca.set_pv_value("MN_PRESSURE:SP", 10) self.ca.set_pv_value("MX_PRESSURE:SP", 100) self.ca.set_pv_value("PRESSURE:SP", 40) - @parameterized.expand([ - (True, "set_em_stop_status", 0, 1, 1), - (True, "set_ru", 1, 1, 1), - (True, "set_re", 2, 1, 1), - (True, "set_stop_bit", 3, 1, 1), - (True, "set_by", 4, 1, 1), - (True, "set_go", 5, 1, 1), - (True, "set_am", 6, 1, 1), - (False, "SERVO", 7, "Closed Loop", 1), - (True, "set_sf_status", 8, 1, 1), - (True, "set_er", 9, 1, 1), - (False, "PRESSURE_RATE", 10, 35, 35), - (False, "MN_PRESSURE", 11, 36, 36), - (False, "MX_PRESSURE", 13, 48, 48) - ]) - def test_WHEN_pv_set_THEN_pv_and_buffer_readback_correctly(self, emulator_backdoor, target, buffer_location, - setpoint_value, buffer_value): + @parameterized.expand( + [ + (True, "set_em_stop_status", 0, 1, 1), + (True, "set_ru", 1, 1, 1), + (True, "set_re", 2, 1, 1), + (True, "set_stop_bit", 3, 1, 1), + (True, "set_by", 4, 1, 1), + (True, "set_go", 5, 1, 1), + (True, "set_am", 6, 1, 1), + (False, "SERVO", 7, "Closed Loop", 1), + (True, "set_sf_status", 8, 1, 1), + (True, "set_er", 9, 1, 1), + (False, "PRESSURE_RATE", 10, 35, 35), + (False, "MN_PRESSURE", 11, 36, 36), + (False, "MX_PRESSURE", 13, 48, 48), + ] + ) + def test_WHEN_pv_set_THEN_pv_and_buffer_readback_correctly( + self, emulator_backdoor, target, buffer_location, setpoint_value, buffer_value + ): # If true, target is the backdoor function. If false its a pv record if emulator_backdoor: self.lewis.backdoor_run_function_on_device(target, [setpoint_value]) @@ -160,7 +166,9 @@ def test_WHEN_General_error_occurs_THEN_general_error_readback_correctly(self): def test_WHEN_error_occurs_THEN_error_translated_correctly(self, _, code, error): self.lewis.backdoor_run_function_on_device("set_er", [code]) self.ca.assert_that_pv_is("ERRCODE", code) - self.ca.assert_that_pv_is("LAST_ERR", error, timeout=1) # Shouldn't be significant delay after previous assert + self.ca.assert_that_pv_is( + "LAST_ERR", error, timeout=1 + ) # Shouldn't be significant delay after previous assert def test_WHEN_value_set_THEN_status_readback_correctly(self): self.ca.set_pv_value("PRESSURE_RATE:SP", 35) @@ -202,7 +210,9 @@ def test_WHEN_device_started_THEN_pump_and_cell_pressures_change_correctly(self) self.ca.assert_that_pv_is("PRESSURE_PUMP", 25) @parameterized.expand(parameterized_list(itertools.product([99, 88], [44, 55]))) - def test_WHEN_difference_set_on_hardware_THEN_can_be_read_back_by_ioc(self, _, cell_pressure, pump_pressure): + def test_WHEN_difference_set_on_hardware_THEN_can_be_read_back_by_ioc( + self, _, cell_pressure, pump_pressure + ): self.lewis.backdoor_run_function_on_device("set_pressures", [pump_pressure, cell_pressure]) self.ca.assert_that_pv_is("PRESSURE_DIFF", cell_pressure - pump_pressure) @@ -266,4 +276,3 @@ def test_WHEN_pressure_is_too_high_THEN_reset_is_disabled(self): self.ca.assert_that_pv_is("PRESSURE", 101) self.ca.assert_that_pv_is("RESET_PRESSURE_TOO_HIGH", "YES") self.ca.assert_that_pv_is("RESET:SP.DISP", "1") - From bcdf7a6591050093b0b4dbddcdab471196bd5447 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 5 Aug 2024 13:52:09 +0100 Subject: [PATCH 3/3] Add ruff linter --- .git-blame-ignore-revs | 2 ++ .github/workflows/linter.yml | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 .git-blame-ignore-revs create mode 100644 .github/workflows/linter.yml diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..a63e09f --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +dad5500447f876c5aebfdb49d8a1cc4593561ce5 +ca3635948d7c51c269d2b4ec00507a39e9822a10 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..72d9425 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,7 @@ +name: Linter +on: [pull_request] +jobs: + call-workflow: + uses: ISISComputingGroup/reusable-workflows/.github/workflows/linters.yml@main + with: + compare-branch: origin/main