2016-11-26 14:33:58 +00:00
|
|
|
import unittest
|
2016-11-07 19:00:10 +00:00
|
|
|
|
2017-01-08 10:28:15 +00:00
|
|
|
from test.example_telegrams import TELEGRAM_V2_2
|
2016-11-07 19:00:10 +00:00
|
|
|
from dsmr_parser.parsers import TelegramParserV2_2
|
|
|
|
from dsmr_parser import telegram_specifications
|
2016-11-20 11:44:45 +00:00
|
|
|
from dsmr_parser import obis_references as obis
|
2016-11-07 19:00:10 +00:00
|
|
|
|
|
|
|
|
2016-11-26 14:33:58 +00:00
|
|
|
class TelegramParserV2_2Test(unittest.TestCase):
|
|
|
|
""" Test parsing of a DSMR v2.2 telegram. """
|
2016-11-07 19:00:10 +00:00
|
|
|
|
2016-11-26 14:33:58 +00:00
|
|
|
def test_parse(self):
|
|
|
|
parser = TelegramParserV2_2(telegram_specifications.V2_2)
|
|
|
|
result = parser.parse(TELEGRAM_V2_2)
|
2016-11-07 19:00:10 +00:00
|
|
|
|
2016-11-26 14:33:58 +00:00
|
|
|
assert float(result[obis.CURRENT_ELECTRICITY_USAGE].value) == 1.01
|
|
|
|
assert result[obis.CURRENT_ELECTRICITY_USAGE].unit == 'kW'
|
2016-11-20 11:44:45 +00:00
|
|
|
|
2016-11-26 14:33:58 +00:00
|
|
|
assert float(result[obis.GAS_METER_READING].value) == 1.001
|
|
|
|
assert result[obis.GAS_METER_READING].unit == 'm3'
|