Exemplo n.º 1
0
 def test_init__valid_values(self, raw_message, pdu_sequence):
     UdsMessage.__init__(self=self.mock_uds_message,
                         raw_message=raw_message,
                         pdu_sequence=pdu_sequence)
     # data validation
     self.mock_uds_message._UdsMessage__validate_raw_message.assert_called_once_with(
         raw_message=raw_message)
     self.mock_uds_message._UdsMessage__validate_pdu_sequence.assert_called_once_with(
         pdu_sequence=pdu_sequence)
     # raw_message verification
     assert isinstance(self.mock_uds_message._UdsMessage__raw_message, tuple), \
         "Value must be converted to tuple to be immutable"
     assert len(self.mock_uds_message._UdsMessage__raw_message) == len(
         raw_message), "Elements must be unchanged"
     assert all(value_set == value_provided
                for value_set, value_provided in zip(
                    self.mock_uds_message._UdsMessage__raw_message,
                    raw_message)), "Elements must be unchanged"
     # pdu_sequence verification
     assert isinstance(self.mock_uds_message._UdsMessage__pdu_sequence, tuple), \
         "Value must be converted to tuple to be immutable"
     assert len(self.mock_uds_message._UdsMessage__pdu_sequence) == len(
         pdu_sequence), "Elements must be unchanged"
     assert all(value_set == value_provided
                for value_set, value_provided in zip(
                    self.mock_uds_message._UdsMessage__pdu_sequence,
                    pdu_sequence)), "Elements must be unchanged"
Exemplo n.º 2
0
 def test_validate_pdu_sequence__wrong_type(self, pdu_sequence):
     with pytest.raises(TypeError):
         UdsMessage._UdsMessage__validate_pdu_sequence(
             pdu_sequence=pdu_sequence)
Exemplo n.º 3
0
 def test_validate_pdu_sequence__valid(self, pdu_sequence):
     assert UdsMessage._UdsMessage__validate_pdu_sequence(
         pdu_sequence=pdu_sequence) is None
Exemplo n.º 4
0
 def test_validate_raw_message__wrong_value(self, raw_message):
     with pytest.raises(ValueError):
         UdsMessage._UdsMessage__validate_raw_message(
             raw_message=raw_message)
Exemplo n.º 5
0
 def test_validate_raw_message__valid(self, raw_message):
     assert UdsMessage._UdsMessage__validate_raw_message(
         raw_message=raw_message) is None
Exemplo n.º 6
0
 def test_init__no_pdus(self, example_raw_message):
     UdsMessage.__init__(self=self.mock_uds_message,
                         raw_message=example_raw_message)
     assert self.mock_uds_message._UdsMessage__pdu_sequence == ()