Skip to content

Commit

Permalink
ruff - i used the old version by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
rerpha committed Dec 12, 2024
1 parent a9fb432 commit e33d522
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 37 deletions.
5 changes: 1 addition & 4 deletions BlockServerToKafka/forwarder_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ def __init__(
self.epics_protocol = epics_protocol

def _create_streams(self, pvs: List[str]) -> List[StreamInfo]:
return [
StreamInfo(pv, self.schema, self.topic, self.epics_protocol, 0)
for pv in pvs
] # pyright: ignore
return [StreamInfo(pv, self.schema, self.topic, self.epics_protocol, 0) for pv in pvs] # pyright: ignore

def create_forwarder_configuration(self, pvs: List[str]) -> bytes:
return serialise_fc00(UpdateType.ADD, self._create_streams(pvs)) # pyright: ignore
Expand Down
8 changes: 2 additions & 6 deletions BlockServerToKafka/test_modules/test_block_server_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def test_WHEN_convert_one_char_to_string_THEN_returns_character(
arr = [ord(c)]
self.assertEqual(c, self.bs_monitor.convert_to_string(bytearray(arr)))

def test_WHEN_convert_many_chars_to_string_THEN_returns_characters(
self, mock_ca_channel
):
def test_WHEN_convert_many_chars_to_string_THEN_returns_characters(self, mock_ca_channel):
chars = "hello world"
arr = [ord(c) for c in chars]
self.assertEqual(chars, self.bs_monitor.convert_to_string(bytearray(arr)))
Expand All @@ -67,9 +65,7 @@ def test_WHEN_convert_chars_with_null_at_start_THEN_nulls_removed(
arr.insert(0, 0)
self.assertEqual(chars, self.bs_monitor.convert_to_string(bytearray(arr)))

def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed(
self, mock_ca_channel
):
def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed(self, mock_ca_channel):
chars = "hello world"
arr = [ord(c) for c in chars]
arr.insert(4, 0)
Expand Down
36 changes: 9 additions & 27 deletions BlockServerToKafka/test_modules/test_forwarder_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,18 @@ def setUp(self):
self.config_with_two_blocks = [self.test_block_1, self.test_block_2]

def test_WHEN_new_forwarder_config_created_THEN_returns_valid_flatbuffers(self):
output = self.kafka_forwarder.create_forwarder_configuration(
self.config_with_one_block
)
output = self.kafka_forwarder.create_forwarder_configuration(self.config_with_one_block)
self.assertTrue(self.is_flatbuffers(output))

def test_WHEN_new_forwarder_config_created_THEN_returns_configuration_update_containing_add_command(
self,
):
raw_output = self.kafka_forwarder.create_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.create_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertEqual(output.config_change, UpdateType.ADD)

def test_WHEN_forwarder_config_removed_THEN_output_has_correct_command_type(self):
raw_output = self.kafka_forwarder.remove_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.remove_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertEqual(output.config_change, UpdateType.REMOVE)

Expand All @@ -75,9 +69,7 @@ def test_WHEN_all_pvs_removed_THEN_output_has_correct_command_type(self):
def test_WHEN_new_forwarder_config_created_THEN_returns_flatbuffer_containing_streams_with_channels_and_converters(
self,
):
raw_output = self.kafka_forwarder.create_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.create_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertNotEqual(0, len(output[1]))
for stream in output[1]:
Expand All @@ -92,9 +84,7 @@ def test_GIVEN_using_version_4_WHEN_new_forwarder_config_created_THEN_returns_JS
epics_protocol=Protocol.PVA, # pyright: ignore noqa
topic=self.test_topic,
)
raw_output = kafka_version_4.create_forwarder_configuration(
self.config_with_one_block
)
raw_output = kafka_version_4.create_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertNotEqual(0, len(output[1]))
for stream in output[1]:
Expand All @@ -103,9 +93,7 @@ def test_GIVEN_using_version_4_WHEN_new_forwarder_config_created_THEN_returns_JS
def test_GIVEN_configuration_with_one_block_WHEN_new_forwarder_config_created_THEN_returns_JSON_containing_one_stream(
self,
):
raw_output = self.kafka_forwarder.create_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.create_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertEqual(1, len(output[1]))

Expand All @@ -121,9 +109,7 @@ def test_GIVEN_configuration_with_two_block_WHEN_new_forwarder_config_created_TH
def test_GIVEN_configuration_with_one_block_WHEN_new_forwarder_config_created_THEN_returns_block_pv_string(
self,
):
raw_output = self.kafka_forwarder.create_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.create_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
stream = output[1][0]
self.assertEqual(self.test_block_1, stream.channel)
Expand All @@ -139,17 +125,13 @@ def test_GIVEN_configuration_with_two_blocks_WHEN_new_forwarder_config_created_T
self.assertTrue(blk in [stream.channel for stream in output[1]])

def test_WHEN_removed_old_forwarder_THEN_JSON_returns_valid(self):
output = self.kafka_forwarder.remove_forwarder_configuration(
self.config_with_one_block
)
output = self.kafka_forwarder.remove_forwarder_configuration(self.config_with_one_block)
self.assertTrue(self.is_flatbuffers(output))

def test_GIVEN_configuration_with_one_block_WHEN_removed_old_forwarder_THEN_returns_JSON_containing_block_pv_string(
self,
):
raw_output = self.kafka_forwarder.remove_forwarder_configuration(
self.config_with_one_block
)
raw_output = self.kafka_forwarder.remove_forwarder_configuration(self.config_with_one_block)
output = deserialise_fc00(raw_output)
self.assertEqual(self.test_block_1, output[1][0].channel)

Expand Down

0 comments on commit e33d522

Please sign in to comment.