used python unittest for the tests

This commit is contained in:
Nigel Dokter
2016-11-26 15:33:58 +01:00
parent 819d0d0696
commit 4df6ba75a2
2 changed files with 164 additions and 161 deletions

View File

@@ -1,4 +1,4 @@
"""Test parsing of a DSMR v2.2 telegram."""
import unittest
from dsmr_parser.parsers import TelegramParserV2_2
from dsmr_parser import telegram_specifications
@@ -28,14 +28,15 @@ TELEGRAM_V2_2 = [
]
def test_parse():
"""Test if telegram parsing results in correct results."""
class TelegramParserV2_2Test(unittest.TestCase):
""" Test parsing of a DSMR v2.2 telegram. """
parser = TelegramParserV2_2(telegram_specifications.V2_2)
result = parser.parse(TELEGRAM_V2_2)
def test_parse(self):
parser = TelegramParserV2_2(telegram_specifications.V2_2)
result = parser.parse(TELEGRAM_V2_2)
assert float(result[obis.CURRENT_ELECTRICITY_USAGE].value) == 1.01
assert result[obis.CURRENT_ELECTRICITY_USAGE].unit == 'kW'
assert float(result[obis.CURRENT_ELECTRICITY_USAGE].value) == 1.01
assert result[obis.CURRENT_ELECTRICITY_USAGE].unit == 'kW'
assert float(result[obis.GAS_METER_READING].value) == 1.001
assert result[obis.GAS_METER_READING].unit == 'm3'
assert float(result[obis.GAS_METER_READING].value) == 1.001
assert result[obis.GAS_METER_READING].unit == 'm3'