finished match_telegram_specification
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from dsmr_parser.exceptions import TelegramSpecificationMatchError
|
||||
from dsmr_parser.parsers import match_telegram_specification
|
||||
from dsmr_parser import telegram_specifications
|
||||
from test import example_telegrams
|
||||
@@ -7,7 +8,6 @@ from test import example_telegrams
|
||||
|
||||
class MatchTelegramSpecificationTest(unittest.TestCase):
|
||||
|
||||
|
||||
def test_v2_2(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V2_2) \
|
||||
== telegram_specifications.V2_2
|
||||
@@ -23,3 +23,7 @@ class MatchTelegramSpecificationTest(unittest.TestCase):
|
||||
def test_v5(self):
|
||||
assert match_telegram_specification(example_telegrams.TELEGRAM_V5) \
|
||||
== telegram_specifications.V5
|
||||
|
||||
def test_malformed_telegram(self):
|
||||
with self.assertRaises(TelegramSpecificationMatchError):
|
||||
match_telegram_specification(example_telegrams.TELEGRAM_V5[:-4])
|
||||
|
||||
@@ -12,6 +12,15 @@ from test.example_telegrams import TELEGRAM_V2_2
|
||||
class TelegramParserV2_2Test(unittest.TestCase):
|
||||
""" Test parsing of a DSMR v2.2 telegram. """
|
||||
|
||||
def test_telegram_specification_matching(self):
|
||||
parser = TelegramParser()
|
||||
parser.parse(TELEGRAM_V2_2)
|
||||
|
||||
self.assertEqual(
|
||||
parser.telegram_specification,
|
||||
telegram_specifications.V2_2
|
||||
)
|
||||
|
||||
def test_parse(self):
|
||||
parser = TelegramParser(telegram_specifications.V2_2)
|
||||
result = parser.parse(TELEGRAM_V2_2)
|
||||
|
||||
@@ -12,6 +12,15 @@ from test.example_telegrams import TELEGRAM_V3
|
||||
class TelegramParserV3Test(unittest.TestCase):
|
||||
""" Test parsing of a DSMR v3 telegram. """
|
||||
|
||||
def test_telegram_specification_matching(self):
|
||||
parser = TelegramParser()
|
||||
parser.parse(TELEGRAM_V3)
|
||||
|
||||
self.assertEqual(
|
||||
parser.telegram_specification,
|
||||
telegram_specifications.V3
|
||||
)
|
||||
|
||||
def test_parse(self):
|
||||
parser = TelegramParser(telegram_specifications.V3)
|
||||
result = parser.parse(TELEGRAM_V3)
|
||||
|
||||
@@ -15,6 +15,15 @@ from test.example_telegrams import TELEGRAM_V4_2
|
||||
class TelegramParserV4_2Test(unittest.TestCase):
|
||||
""" Test parsing of a DSMR v4.2 telegram. """
|
||||
|
||||
def test_telegram_specification_matching(self):
|
||||
parser = TelegramParser()
|
||||
parser.parse(TELEGRAM_V4_2)
|
||||
|
||||
self.assertEqual(
|
||||
parser.telegram_specification,
|
||||
telegram_specifications.V4
|
||||
)
|
||||
|
||||
def test_parse(self):
|
||||
parser = TelegramParser(telegram_specifications.V4)
|
||||
result = parser.parse(TELEGRAM_V4_2)
|
||||
|
||||
@@ -16,6 +16,15 @@ from test.example_telegrams import TELEGRAM_V5
|
||||
class TelegramParserV5Test(unittest.TestCase):
|
||||
""" Test parsing of a DSMR v5.x telegram. """
|
||||
|
||||
def test_telegram_specification_matching(self):
|
||||
parser = TelegramParser()
|
||||
parser.parse(TELEGRAM_V5)
|
||||
|
||||
self.assertEqual(
|
||||
parser.telegram_specification,
|
||||
telegram_specifications.V5
|
||||
)
|
||||
|
||||
def test_parse(self):
|
||||
parser = TelegramParser(telegram_specifications.V5)
|
||||
result = parser.parse(TELEGRAM_V5)
|
||||
|
||||
Reference in New Issue
Block a user