def test_check_checksum_raises_exception_if_checksum_invalid( self, simple_encoded_msg): with pytest.raises(ParsingError): encoded_msg = simple_encoded_msg[:-4] + b"123" + settings.SOH DecoderApp.check_checksum(encoded_msg, 0, 19)
def test_check_checksum_not_found_raises_exception(self, simple_encoded_msg): with pytest.raises(ParsingError): encoded_msg = simple_encoded_msg[:-7] DecoderApp.check_checksum(encoded_msg)
def test_check_checksum_trailing_bytes_raises_exception( self, simple_encoded_msg): with pytest.raises(ParsingError): message = simple_encoded_msg + b"34=1" + settings.SOH DecoderApp.check_checksum(message)
def test_check_checksum(self, simple_encoded_msg): checksum, _ = DecoderApp.check_checksum(simple_encoded_msg) assert checksum == 163