Changed spider/spot <id> to <address>

pull/62/head
Konstantin Gründger 2018-04-28 18:45:23 +02:00
rodzic 8c874a3226
commit fabb92bc88
4 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -12,7 +12,7 @@ class SpiderParser(BaseParser):
@staticmethod
def parse_position(aprs_comment):
ac_match = re.search(PATTERN_SPIDER_POSITION_COMMENT, aprs_comment)
return {'id': ac_match.group('id'),
return {'address': ac_match.group('id'),
'signal_power': int(ac_match.group('signal_power')) if ac_match.group('signal_power') else None,
'spider_id': ac_match.group('spider_id') if ac_match.group('spider_id') else None,
'gps_quality': ac_match.group('gps_quality') if ac_match.group('gps_quality') else None}

Wyświetl plik

@ -12,6 +12,6 @@ class SpotParser(BaseParser):
@staticmethod
def parse_position(aprs_comment):
ac_match = re.search(PATTERN_SPOT_POSITION_COMMENT, aprs_comment)
return {'id': ac_match.group('id'),
return {'address': ac_match.group('id'),
'model': int(ac_match.group('model')) if ac_match.group('model') else None,
'status': ac_match.group('status') if ac_match.group('status') else None}

Wyświetl plik

@ -7,7 +7,7 @@ class TestStringMethods(unittest.TestCase):
def test_position_comment(self):
message = SpiderParser.parse_position("id300234010617040 +19dB LWE 3D")
self.assertEqual(message['id'], "300234010617040")
self.assertEqual(message['address'], "300234010617040")
self.assertEqual(message['signal_power'], 19)
self.assertEqual(message['spider_id'], "LWE")
self.assertEqual(message['gps_quality'], "3D")

Wyświetl plik

@ -7,7 +7,7 @@ class TestStringMethods(unittest.TestCase):
def test_position_comment(self):
message = SpotParser.parse_position("id0-2860357 SPOT3 GOOD")
self.assertEqual(message['id'], "0-2860357")
self.assertEqual(message['address'], "0-2860357")
self.assertEqual(message['model'], 3)
self.assertEqual(message['status'], "GOOD")