Skip to content

Commit

Permalink
Quickfix for typing improvement (#240)
Browse files Browse the repository at this point in the history
Fix previously overlooked issues - adjust tests to go through all paths.
  • Loading branch information
mdabrowski1990 authored Oct 24, 2023
1 parent cc8d776 commit 2def9d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions tests/software_tests/can/test_mixed_addressing_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def test_validate_packet_ai__missing_info(self, addressing_type, can_id,
@pytest.mark.parametrize("address_extension", ["some AE", 0x5B])
def test_validate_packet_ai__inconsistent_can_id_ta_sa(self, can_id, addressing_type, decoded_addressing_type,
ta, decoded_ta, sa, decoded_sa, address_extension):
self.mock_validate_addressing_type.return_value = addressing_type
self.mock_can_id_handler_class.decode_mixed_addressed_29bit_can_id.return_value = {
self.mock_can_id_handler_class.ADDRESSING_TYPE_NAME: decoded_addressing_type,
self.mock_can_id_handler_class.TARGET_ADDRESS_NAME: decoded_ta,
Expand Down Expand Up @@ -164,7 +165,7 @@ def test_validate_packet_ai__valid_without_can_id(self, addressing_type,
source_address=source_address,
address_extension=address_extension) == {
AbstractCanAddressingInformation.ADDRESSING_FORMAT_NAME: CanAddressingFormat.MIXED_29BIT_ADDRESSING,
AbstractCanAddressingInformation.ADDRESSING_TYPE_NAME: addressing_type,
AbstractCanAddressingInformation.ADDRESSING_TYPE_NAME: self.mock_validate_addressing_type.return_value,
AbstractCanAddressingInformation.CAN_ID_NAME: self.mock_can_id_handler_class.encode_mixed_addressed_29bit_can_id.return_value,
AbstractCanAddressingInformation.TARGET_ADDRESS_NAME: target_address,
AbstractCanAddressingInformation.SOURCE_ADDRESS_NAME: source_address,
Expand All @@ -176,7 +177,7 @@ def test_validate_packet_ai__valid_without_can_id(self, addressing_type,
self.mock_can_id_handler_class.validate_can_id.assert_not_called()
self.mock_can_id_handler_class.decode_mixed_addressed_29bit_can_id.assert_not_called()
self.mock_can_id_handler_class.encode_mixed_addressed_29bit_can_id.assert_called_once_with(
addressing_type=addressing_type,
addressing_type=self.mock_validate_addressing_type.return_value,
target_address=target_address,
source_address=source_address)

Expand All @@ -193,7 +194,7 @@ def test_validate_packet_ai__valid_with_can_id(self, addressing_type, can_id,
decoded_target_address = target_address or "ta"
decoded_source_address = source_address or "sa"
self.mock_can_id_handler_class.decode_mixed_addressed_29bit_can_id.return_value = {
self.mock_can_id_handler_class.ADDRESSING_TYPE_NAME: addressing_type,
self.mock_can_id_handler_class.ADDRESSING_TYPE_NAME: self.mock_validate_addressing_type.return_value,
self.mock_can_id_handler_class.TARGET_ADDRESS_NAME: decoded_target_address,
self.mock_can_id_handler_class.SOURCE_ADDRESS_NAME: decoded_source_address,
}
Expand All @@ -203,7 +204,7 @@ def test_validate_packet_ai__valid_with_can_id(self, addressing_type, can_id,
source_address=source_address,
address_extension=address_extension) == {
AbstractCanAddressingInformation.ADDRESSING_FORMAT_NAME: CanAddressingFormat.MIXED_29BIT_ADDRESSING,
AbstractCanAddressingInformation.ADDRESSING_TYPE_NAME: addressing_type,
AbstractCanAddressingInformation.ADDRESSING_TYPE_NAME: self.mock_validate_addressing_type.return_value,
AbstractCanAddressingInformation.CAN_ID_NAME: can_id,
AbstractCanAddressingInformation.TARGET_ADDRESS_NAME: decoded_target_address,
AbstractCanAddressingInformation.SOURCE_ADDRESS_NAME: decoded_source_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def test_validate_packet_ai__missing_info(self, addressing_type, can_id,
])
def test_validate_packet_ai__inconsistent_can_id_ta_sa(self, can_id, addressing_type, decoded_addressing_type,
ta, decoded_ta, sa, decoded_sa):
self.mock_validate_addressing_type.return_value = addressing_type
self.mock_can_id_handler_class.decode_normal_fixed_addressed_can_id.return_value = {
self.mock_can_id_handler_class.ADDRESSING_TYPE_NAME: decoded_addressing_type,
self.mock_can_id_handler_class.TARGET_ADDRESS_NAME: decoded_ta,
Expand Down
2 changes: 1 addition & 1 deletion uds/can/mixed_addressing_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def validate_packet_ai(cls,
:return: Normalized dictionary with the provided Addressing Information.
"""
AddressingType.validate_member(addressing_type)
addressing_type = AddressingType.validate_member(addressing_type)
validate_raw_byte(address_extension) # type: ignore
if can_id is None:
if None in (target_address, source_address):
Expand Down

0 comments on commit 2def9d3

Please sign in to comment.