22 lines
720 B
Python
Raw Normal View History

2019-06-06 03:41:55 +00:00
import unittest
from dsmr_parser import telegram_specifications
from dsmr_parser.objects import CosemObject
from dsmr_parser.objects import Telegram
2019-06-06 03:41:55 +00:00
from dsmr_parser.parsers import TelegramParser
from test.example_telegrams import TELEGRAM_V4_2
2019-06-06 03:41:55 +00:00
class TelegramTest(unittest.TestCase):
""" Test instantiation of Telegram object """
def test_instantiate(self):
parser = TelegramParser(telegram_specifications.V4)
telegram = Telegram(TELEGRAM_V4_2, parser, telegram_specifications.V4)
# P1_MESSAGE_HEADER (1-3:0.2.8)
testitem = telegram.P1_MESSAGE_HEADER
assert isinstance(testitem, CosemObject)
assert testitem.unit is None
assert testitem.value == '42'