kopia lustrzana https://github.com/glidernet/python-ogn-client
Added test for receiver OGNSDR
rodzic
7361ea7392
commit
e1247467e5
|
@ -45,7 +45,7 @@ def parse_aprs(message, reference_date=None, reference_time=None):
|
|||
'track': int(match_position.group('course')) if match_position.group('course_extension') else None,
|
||||
'ground_speed': int(match_position.group('ground_speed')) * kts2kmh if match_position.group('ground_speed') else None,
|
||||
'altitude': int(match_position.group('altitude')) * feet2m,
|
||||
'comment': match_position.group('comment'),
|
||||
'comment': match_position.group('comment') if match_position.group('comment') else "",
|
||||
'aprs_type': 'position'}
|
||||
|
||||
match_status = re.search(PATTERN_APRS_STATUS, message)
|
||||
|
@ -54,7 +54,7 @@ def parse_aprs(message, reference_date=None, reference_time=None):
|
|||
'dstcall': match_status.group('dstcall'),
|
||||
'receiver_name': match_status.group('receiver'),
|
||||
'timestamp': createTimestamp(match_status.group('time'), reference_date, reference_time),
|
||||
'comment': match_status.group('comment'),
|
||||
'comment': match_status.group('comment') if match_status.group('comment') else "",
|
||||
'aprs_type': 'status'}
|
||||
|
||||
raise AprsParseError(message)
|
||||
|
|
|
@ -4,8 +4,11 @@ from ogn.parser.pattern import PATTERN_RECEIVER_POSITION, PATTERN_RECEIVER_STATU
|
|||
|
||||
|
||||
def parse_position(aprs_comment):
|
||||
match = re.search(PATTERN_RECEIVER_POSITION, aprs_comment)
|
||||
return {'user_comment': match.group('user_comment') if match.group('user_comment') else None}
|
||||
if aprs_comment is None:
|
||||
return {}
|
||||
else:
|
||||
match = re.search(PATTERN_RECEIVER_POSITION, aprs_comment)
|
||||
return {'user_comment': match.group('user_comment') if match.group('user_comment') else None}
|
||||
|
||||
|
||||
def parse_status(aprs_comment):
|
||||
|
|
|
@ -55,7 +55,7 @@ class TestStringMethods(unittest.TestCase):
|
|||
raw_message = "Ulrichamn>APRS,TCPIP*,qAC,GLIDERN1:/085616h5747.30NI01324.77E&/A=001322"
|
||||
message = parse_aprs(raw_message, reference_date=datetime(2015, 1, 1, 8, 56, 0))
|
||||
|
||||
self.assertEqual(message['comment'], None)
|
||||
self.assertEqual(message['comment'], '')
|
||||
|
||||
def test_v026_relay(self):
|
||||
# beacons can be relayed
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import unittest
|
||||
|
||||
from ogn.parser.parse_receiver import parse_position, parse_status
|
||||
|
||||
|
||||
class TestStringMethods(unittest.TestCase):
|
||||
def test_position(self):
|
||||
message = parse_position("Antenna: chinese, on a pylon, 20 meter above ground")
|
||||
|
||||
self.assertEqual(message['user_comment'], "Antenna: chinese, on a pylon, 20 meter above ground")
|
||||
|
||||
def test_position_empty(self):
|
||||
message = parse_position("")
|
||||
|
||||
self.assertIsNotNone(message)
|
||||
|
||||
def test_status(self):
|
||||
message = parse_status("v0.2.7.RPI-GPU CPU:0.7 RAM:770.2/968.2MB NTP:1.8ms/-3.3ppm +55.7C 7/8Acfts[1h] RF:+54-1.1ppm/-0.16dB/+7.1dB@10km[19481]/+16.8dB@10km[7/13]")
|
||||
|
||||
self.assertEqual(message['version'], "0.2.7")
|
||||
self.assertEqual(message['platform'], 'RPI-GPU')
|
||||
self.assertEqual(message['cpu_load'], 0.7)
|
||||
self.assertEqual(message['free_ram'], 770.2)
|
||||
self.assertEqual(message['total_ram'], 968.2)
|
||||
self.assertEqual(message['ntp_error'], 1.8)
|
||||
self.assertEqual(message['rt_crystal_correction'], -3.3)
|
||||
self.assertEqual(message['cpu_temp'], 55.7)
|
||||
self.assertEqual(message['senders_visible'], 7)
|
||||
self.assertEqual(message['senders_total'], 8)
|
||||
self.assertEqual(message['rec_crystal_correction'], 54)
|
||||
self.assertEqual(message['rec_crystal_correction_fine'], -1.1)
|
||||
self.assertEqual(message['rec_input_noise'], -0.16)
|
||||
self.assertEqual(message['senders_signal'], 7.1)
|
||||
self.assertEqual(message['senders_messages'], 19481)
|
||||
self.assertEqual(message['good_senders_signal'], 16.8)
|
||||
self.assertEqual(message['good_senders'], 7)
|
||||
self.assertEqual(message['good_and_bad_senders'], 13)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Ładowanie…
Reference in New Issue