Fix parsing tests and line start matching (#132)

* Raise parsing exception and check it in tests

* use multiline regex and match everything at the line start
This commit is contained in:
dupondje
2023-04-14 16:51:01 +02:00
committed by GitHub
parent ae8a2baaab
commit 84973872af
8 changed files with 119 additions and 96 deletions
+4 -1
View File
@@ -18,7 +18,10 @@ class TelegramParserFluviusTest(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.BELGIUM_FLUVIUS)
result = parser.parse(TELEGRAM_FLUVIUS_V171)
try:
result = parser.parse(TELEGRAM_FLUVIUS_V171, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# BELGIUM_VERSION_INFORMATION (0-0:96.1.4)
assert isinstance(result[obis.BELGIUM_VERSION_INFORMATION], CosemObject)
+4 -1
View File
@@ -15,7 +15,10 @@ class TelegramParserIskraIETest(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.ISKRA_IE)
result = parser.parse(TELEGRAM_ISKRA_IE)
try:
result = parser.parse(TELEGRAM_ISKRA_IE, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# EQUIPMENT_IDENTIFIER_GAS (0-0:96.1.0)
assert isinstance(result[obis.EQUIPMENT_IDENTIFIER_GAS], CosemObject)
+4 -1
View File
@@ -14,7 +14,10 @@ class TelegramParserV2_2Test(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.V2_2)
result = parser.parse(TELEGRAM_V2_2)
try:
result = parser.parse(TELEGRAM_V2_2, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# ELECTRICITY_USED_TARIFF_1 (1-0:1.8.1)
assert isinstance(result[obis.ELECTRICITY_USED_TARIFF_1], CosemObject)
+4 -1
View File
@@ -14,7 +14,10 @@ class TelegramParserV3Test(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.V3)
result = parser.parse(TELEGRAM_V3)
try:
result = parser.parse(TELEGRAM_V3, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# ELECTRICITY_USED_TARIFF_1 (1-0:1.8.1)
assert isinstance(result[obis.ELECTRICITY_USED_TARIFF_1], CosemObject)
+4 -1
View File
@@ -17,7 +17,10 @@ class TelegramParserV4_2Test(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.V4)
result = parser.parse(TELEGRAM_V4_2)
try:
result = parser.parse(TELEGRAM_V4_2, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# P1_MESSAGE_HEADER (1-3:0.2.8)
assert isinstance(result[obis.P1_MESSAGE_HEADER], CosemObject)
+4 -1
View File
@@ -17,7 +17,10 @@ class TelegramParserV5Test(unittest.TestCase):
def test_parse(self):
parser = TelegramParser(telegram_specifications.V5)
telegram = parser.parse(TELEGRAM_V5)
try:
telegram = parser.parse(TELEGRAM_V5, throw_ex=True)
except Exception as ex:
assert False, f"parse trigged an exception {ex}"
# P1_MESSAGE_HEADER (1-3:0.2.8)
assert isinstance(telegram.P1_MESSAGE_HEADER, CosemObject)