issue-51-telegram refactored TelegramParser.parse to return Telegram object. Telegram object now does not do parsing anymore.
This commit is contained in:
@@ -3,6 +3,6 @@ from dsmr_parser.objects import Telegram
|
||||
from dsmr_parser.parsers import TelegramParser
|
||||
from example_telegrams import TELEGRAM_V4_2
|
||||
parser = TelegramParser(telegram_specifications.V4)
|
||||
telegram = Telegram(TELEGRAM_V4_2, parser, telegram_specifications.V4)
|
||||
telegram = parser.parse(TELEGRAM_V4_2)
|
||||
|
||||
print(telegram)
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestParserCornerCases(unittest.TestCase):
|
||||
def test_power_event_log_empty_1(self):
|
||||
# POWER_EVENT_FAILURE_LOG (1-0:99.97.0)
|
||||
parser = TelegramParser(telegram_specifications.V5)
|
||||
telegram = Telegram(TELEGRAM_V5, parser, telegram_specifications.V5)
|
||||
telegram = parser.parse(TELEGRAM_V5)
|
||||
|
||||
object_type = ProfileGenericObject
|
||||
testitem = telegram.POWER_EVENT_FAILURE_LOG
|
||||
|
||||
@@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
from dsmr_parser import obis_references as obis
|
||||
from dsmr_parser.clients.protocol import create_dsmr_protocol
|
||||
|
||||
from dsmr_parser.objects import Telegram
|
||||
|
||||
TELEGRAM_V2_2 = (
|
||||
'/ISk5\2MT382-1004\r\n'
|
||||
@@ -44,7 +44,7 @@ class ProtocolTest(unittest.TestCase):
|
||||
self.protocol.data_received(TELEGRAM_V2_2.encode('ascii'))
|
||||
|
||||
telegram = self.protocol.telegram_callback.call_args_list[0][0][0]
|
||||
assert isinstance(telegram, dict)
|
||||
assert isinstance(telegram, Telegram)
|
||||
|
||||
assert float(telegram[obis.CURRENT_ELECTRICITY_USAGE].value) == 1.01
|
||||
assert telegram[obis.CURRENT_ELECTRICITY_USAGE].unit == 'kW'
|
||||
|
||||
@@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
from dsmr_parser import obis_references as obis
|
||||
from dsmr_parser.clients.rfxtrx_protocol import create_rfxtrx_dsmr_protocol, PACKETTYPE_DSMR, SUBTYPE_P1
|
||||
|
||||
from dsmr_parser.objects import Telegram
|
||||
|
||||
TELEGRAM_V2_2 = (
|
||||
'/ISk5\2MT382-1004\r\n'
|
||||
@@ -68,7 +68,7 @@ class RFXtrxProtocolTest(unittest.TestCase):
|
||||
self.protocol.data_received(data[200:])
|
||||
|
||||
telegram = self.protocol.telegram_callback.call_args_list[0][0][0]
|
||||
assert isinstance(telegram, dict)
|
||||
assert isinstance(telegram, Telegram)
|
||||
|
||||
assert float(telegram[obis.CURRENT_ELECTRICITY_USAGE].value) == 1.01
|
||||
assert telegram[obis.CURRENT_ELECTRICITY_USAGE].unit == 'kW'
|
||||
|
||||
@@ -30,7 +30,7 @@ class TelegramTest(unittest.TestCase):
|
||||
|
||||
def test_instantiate(self):
|
||||
parser = TelegramParser(telegram_specifications.V4)
|
||||
telegram = Telegram(TELEGRAM_V4_2, parser, telegram_specifications.V4)
|
||||
telegram = parser.parse(TELEGRAM_V4_2)
|
||||
|
||||
# P1_MESSAGE_HEADER (1-3:0.2.8)
|
||||
self.verify_telegram_item(telegram,
|
||||
|
||||
Reference in New Issue
Block a user