Ejemplo n.º 1
0
    def test_checksum_invalid(self):
        # Remove the electricty used data value. This causes the checksum to
        # not match anymore.
        corrupted_telegram = TELEGRAM_V5.replace(
            '1-0:1.8.1(000004.426*kWh)\r\n', '')

        with self.assertRaises(InvalidChecksumError):
            TelegramParser.validate_checksum(corrupted_telegram)
Ejemplo n.º 2
0
    def test_checksum_missing(self):
        # Remove the checksum value causing a ParseError.
        corrupted_telegram = TELEGRAM_V5.replace('!87B3\r\n', '')

        with self.assertRaises(ParseContentError):
            TelegramParser.validate_checksum(corrupted_telegram)
Ejemplo n.º 3
0
 def test_checksum_valid(self):
     # ParseErrorV4 should be raised.
     with self.assertRaises(NoChecksumError):
         TelegramParser.validate_checksum(TELEGRAM_V3)
Ejemplo n.º 4
0
 def test_checksum_valid(self):
     # No exception is raised.
     TelegramParser.validate_checksum(TELEGRAM_V5)
Ejemplo n.º 5
0
    def test_checksum_invalid(self):
        corrupted_telegram = TELEGRAM_V2_2.replace('!\r\n', '')

        with self.assertRaises(ParseContentError):
            TelegramParser.validate_checksum(corrupted_telegram)