fix tox tests

This commit is contained in:
Hans Erik van Elburg 2020-12-24 01:52:17 +01:00
parent 5b1e830018
commit 81cccbd228
4 changed files with 5 additions and 8 deletions

View File

@ -63,6 +63,6 @@ ELECTRICITY_DELIVERED_TARIFF_ALL = (
# Alternate codes for foreign countries. # Alternate codes for foreign countries.
BELGIUM_HOURLY_GAS_METER_READING = r'\d-\d:24\.2\.3.+?\r\n' # Different code, same format. BELGIUM_HOURLY_GAS_METER_READING = r'\d-\d:24\.2\.3.+?\r\n' # Different code, same format.
LUXEMBOURG_EQUIPMENT_IDENTIFIER = r'\d-\d:42\.0\.0.+?\r\n' # Logical device name LUXEMBOURG_EQUIPMENT_IDENTIFIER = r'\d-\d:42\.0\.0.+?\r\n' # Logical device name
LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL = r'\d-\d:1\.8\.0.+?\r\n' # Total imported energy register (P+) LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL = r'\d-\d:1\.8\.0.+?\r\n' # Total imported energy register (P+)
LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL = r'\d-\d:2\.8\.0.+?\r\n' # Total exported energy register (P-) LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL = r'\d-\d:2\.8\.0.+?\r\n' # Total exported energy register (P-)

View File

@ -225,8 +225,6 @@ class ProfileGenericParser(DSMRObjectParser):
self.parsers_for_unidentified = parsers_for_unidentified self.parsers_for_unidentified = parsers_for_unidentified
def _is_line_wellformed(self, line, values): def _is_line_wellformed(self, line, values):
if values and (len(values) == 1) and (values[0] == ''): if values and (len(values) == 1) and (values[0] == ''):
# special case: single empty parentheses (indicated by empty string) # special case: single empty parentheses (indicated by empty string)
return True return True
@ -238,9 +236,9 @@ class ProfileGenericParser(DSMRObjectParser):
return False return False
def _parse_values(self, values): def _parse_values(self, values):
if values and (len(values) == 1) and (values[0] == None): if values and (len(values) == 1) and (values[0] is None):
# special case: single empty parentheses; make sure empty ProfileGenericObject is created # special case: single empty parentheses; make sure empty ProfileGenericObject is created
values = [0, None] # buffer_length=0, buffer_value_obis_ID=None values = [0, None] # buffer_length=0, buffer_value_obis_ID=None
buffer_length = int(values[0]) buffer_length = int(values[0])
buffer_value_obis_ID = values[1] buffer_value_obis_ID = values[1]
if (buffer_length > 0): if (buffer_length > 0):

View File

@ -127,4 +127,4 @@ TELEGRAM_V5 = (
'0-2:24.1.0(003)\r\n' '0-2:24.1.0(003)\r\n'
'0-2:96.1.0()\r\n' '0-2:96.1.0()\r\n'
'!6EEE\r\n' '!6EEE\r\n'
) )

View File

@ -241,7 +241,6 @@ class TelegramParserV5Test(unittest.TestCase):
def test_checksum_missing(self): def test_checksum_missing(self):
# Remove the checksum value causing a ParseError. # Remove the checksum value causing a ParseError.
corrupted_telegram = TELEGRAM_V5.replace('!87B3\r\n', '') corrupted_telegram = TELEGRAM_V5.replace('!6EEE\r\n', '')
with self.assertRaises(ParseError): with self.assertRaises(ParseError):
TelegramParser.validate_checksum(corrupted_telegram) TelegramParser.validate_checksum(corrupted_telegram)