From 7682a69fd76470bfe68eb46549c304555c719138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Fri, 7 Jun 2019 20:45:07 +0200 Subject: [PATCH] Fixed inReach parser --- ogn/parser/aprs_comment/inreach_parser.py | 2 +- tests/parser/test_parse_generic.py | 16 ++++++++++++++++ tests/parser/valid_beacon_data/inreach.txt | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/parser/test_parse_generic.py create mode 100644 tests/parser/valid_beacon_data/inreach.txt diff --git a/ogn/parser/aprs_comment/inreach_parser.py b/ogn/parser/aprs_comment/inreach_parser.py index aea7cbd..2229450 100644 --- a/ogn/parser/aprs_comment/inreach_parser.py +++ b/ogn/parser/aprs_comment/inreach_parser.py @@ -14,5 +14,5 @@ class InreachParser(BaseParser): ac_match = self.position_pattern.match(aprs_comment) return {'address': ac_match.group('id'), 'model': ac_match.group('model') if ac_match.group('model') else None, - 'status': ac_match.group('status') == True if ac_match.group('status') else None, + 'status': ac_match.group('status') == 'True' if ac_match.group('status') else None, 'pilot_name': ac_match.group('pilot_name') if ac_match.group('pilot_name') else None} diff --git a/tests/parser/test_parse_generic.py b/tests/parser/test_parse_generic.py new file mode 100644 index 0000000..01f6516 --- /dev/null +++ b/tests/parser/test_parse_generic.py @@ -0,0 +1,16 @@ +import unittest + +from ogn.parser.aprs_comment.generic_parser import GenericParser + + +class TestStringMethods(unittest.TestCase): + def test_position_comment(self): + message = GenericParser().parse_position("id0123456789 weather is good, climbing with 123fpm") + self.assertTrue('comment' in message) + + message = GenericParser().parse_status("id0123456789 weather is good, climbing with 123fpm") + self.assertTrue('comment' in message) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/parser/valid_beacon_data/inreach.txt b/tests/parser/valid_beacon_data/inreach.txt new file mode 100644 index 0000000..0a3abd5 --- /dev/null +++ b/tests/parser/valid_beacon_data/inreach.txt @@ -0,0 +1,4 @@ +# The following beacons are example for INREACH APRS format +# source: https://github.com/glidernet/ogn-aprs-protocol +# +OGN8A0749>OGINREACH,qAS,INREACH:/142700h0448.38N/07600.74W'000/000/A=004583 id300434060496190 inReac True \ No newline at end of file