Skip to content

Commit

Permalink
rework system tests
Browse files Browse the repository at this point in the history
- 2system tests clasess (for packets and messages) are working
- fix n_bs defect (constant instead of variable was used during messages transmission)
  • Loading branch information
mdabrowski1990 committed Oct 25, 2024
1 parent a50979d commit 91f0fe1
Show file tree
Hide file tree
Showing 4 changed files with 537 additions and 407 deletions.
32 changes: 16 additions & 16 deletions tests/software_tests/transport_interface/can/test_python_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ def test_send_message__multiple_packets__st_min__block_size_0(self, message, st_
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT)
timeout=self.mock_can_transport_interface.n_bs_timeout)
self.mock_can_transport_interface._send_cf_packets_block.assert_called_once_with(
cf_packets_block=mock_segmented_message[1:],
delay=self.mock_can_st_min_handler.decode.return_value)
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def test_send_message__multiple_packets__n_cs__block_size_1(self, message, n_cs,
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT) for _ in mock_segmented_message[1:]
call(timeout=self.mock_can_transport_interface.n_bs_timeout) for _ in mock_segmented_message[1:]
])
self.mock_can_transport_interface._send_cf_packets_block.assert_has_calls([
call(cf_packets_block=[packet], delay=n_cs) for packet in mock_segmented_message[1:]
Expand Down Expand Up @@ -1245,8 +1245,8 @@ def test_send_message__multiple_packets__wait(self, message):
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT),
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT)
call(timeout=self.mock_can_transport_interface.n_bs_timeout),
call(timeout=self.mock_can_transport_interface.n_bs_timeout)
])
self.mock_uds_message_record.assert_called_once_with([
self.mock_can_transport_interface.send_packet.return_value,
Expand Down Expand Up @@ -1282,8 +1282,8 @@ def test_send_message__multiple_packets__unexpected_packet(self, message):
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT),
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT)
call(timeout=self.mock_can_transport_interface.n_bs_timeout),
call(timeout=self.mock_can_transport_interface.n_bs_timeout)
])
self.mock_uds_message_record.assert_called_once_with([
self.mock_can_transport_interface.send_packet.return_value,
Expand Down Expand Up @@ -1311,7 +1311,7 @@ def test_send_message__multiple_packets__overflow(self, message):
PyCanTransportInterface.send_message(self.mock_can_transport_interface, message)
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT)
timeout=self.mock_can_transport_interface.n_bs_timeout)
self.mock_warn.assert_not_called()
self.mock_can_transport_interface._update_n_bs_measured.assert_not_called()

Expand All @@ -1332,7 +1332,7 @@ def test_send_message__multiple_packets__unknown_flow_status(self, message):
PyCanTransportInterface.send_message(self.mock_can_transport_interface, message)
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT)
timeout=self.mock_can_transport_interface.n_bs_timeout)
self.mock_warn.assert_not_called()
self.mock_can_transport_interface._update_n_bs_measured.assert_not_called()

Expand Down Expand Up @@ -1379,7 +1379,7 @@ async def test_async_send_message__multiple_packets__st_min__block_size_0(self,
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None)
timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None)
self.mock_can_transport_interface._async_send_cf_packets_block.assert_called_once_with(
cf_packets_block=mock_segmented_message[1:],
delay=self.mock_can_st_min_handler.decode.return_value,
Expand Down Expand Up @@ -1421,7 +1421,7 @@ async def test_async_send_message__multiple_packets__n_cs__block_size_1(self, me
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None) for _ in mock_segmented_message[1:]
call(timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None) for _ in mock_segmented_message[1:]
])
self.mock_can_transport_interface._async_send_cf_packets_block.assert_has_calls([
call(cf_packets_block=[packet], delay=n_cs, loop=None) for packet in mock_segmented_message[1:]
Expand Down Expand Up @@ -1460,8 +1460,8 @@ async def test_async_send_message__multiple_packets__wait(self, message):
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None),
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None)
call(timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None),
call(timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None)
])
self.mock_uds_message_record.assert_called_once_with([
self.mock_can_transport_interface.async_send_packet.return_value,
Expand Down Expand Up @@ -1497,8 +1497,8 @@ async def test_async_send_message__multiple_packets__unexpected_packet(self, mes
self.mock_can_transport_interface, message) == self.mock_uds_message_record.return_value
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_has_calls([
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None),
call(timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None)
call(timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None),
call(timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None)
])
self.mock_uds_message_record.assert_called_once_with([
self.mock_can_transport_interface.async_send_packet.return_value,
Expand Down Expand Up @@ -1528,7 +1528,7 @@ async def test_async_send_message__multiple_packets__overflow(self, message):
await PyCanTransportInterface.async_send_message(self.mock_can_transport_interface, message)
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None)
timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None)
self.mock_warn.assert_not_called()
self.mock_can_transport_interface._update_n_bs_measured.assert_not_called()

Expand All @@ -1551,7 +1551,7 @@ async def test_async_send_message__multiple_packets__unknown_flow_status(self, m
await PyCanTransportInterface.async_send_message(self.mock_can_transport_interface, message)
self.mock_can_transport_interface.segmenter.segmentation.assert_called_once_with(message)
self.mock_can_transport_interface.async_receive_packet.assert_called_once_with(
timeout=self.mock_can_transport_interface.N_BS_TIMEOUT, loop=None)
timeout=self.mock_can_transport_interface.n_bs_timeout, loop=None)
self.mock_warn.assert_not_called()
self.mock_can_transport_interface._update_n_bs_measured.assert_not_called()

Expand Down
Loading

0 comments on commit 91f0fe1

Please sign in to comment.