Repository: akolar/ogn-lib

Issue:
Implement parser for Spider messages (OGSPID)

Discussion:

Patch:
diff --git a/ogn_lib/parser.py b/ogn_lib/parser.py
index a2ca7ea..00093ea 100644
--- a/ogn_lib/parser.py
+++ b/ogn_lib/parser.py
@@ -629,31 +629,32 @@ class ServerParser(Parser):
         return {'comment': comment}
 
 
-class Spot(Parser):
+class Spider(Parser):
     """
-    Parser for Spot-formatted APRS messages.
+    Parser for Spider-formatted APRS messages.
     """
 
-    __destto__ = ['OGSPOT', 'OGSPOT-1']
+    __destto__ = ['OGSPID', 'OGSPID-1']
 
     @staticmethod
     def _parse_protocol_specific(comment):
         """
-        Parses the comment string from Spot's APRS messages.
+        Parses the comment string from Spider's APRS messages.
 
         :param str comment: comment string
         :return: parsed comment
         :rtype: dict
         """
 
-        fields = comment.split(' ', maxsplit=2)
+        fields = comment.split(' ', maxsplit=3)
 
-        if len(fields) < 3:
-            raise exceptions.ParseError('SPOT comment incorrectly formatted: '
-                                        'received {}'.format(comment))
+        if len(fields) < 4:
+            raise exceptions.ParseError('Spider comment incorrectly formatted:'
+                                        ' received {}'.format(comment))
 
         return {
             'id': fields[0],
-            'model': fields[1],
-            'status': fields[2]
+            'signal_strength': fields[1],
+            'spider_id': fields[2],
+            'gps_status': fields[3]
         }


Test patch:
diff --git a/tests/test_parser.py b/tests/test_parser.py
index bcd3247..f179511 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -442,14 +442,16 @@ class TestNaviter:
 
 class TestSpot:
     def test_parse_protocol_specific(self):
-        data = parser.Spot._parse_protocol_specific('id0-2860357 SPOT3 GOOD')
-        assert data['id'] == 'id0-2860357'
-        assert data['model'] == 'SPOT3'
-        assert data['status'] == 'GOOD'
+        data = parser.Spider._parse_protocol_specific('id300234010617040 +19dB'
+                                                      ' LWE 3D')
+        assert data['id'] == 'id300234010617040'
+        assert data['signal_strength'] == '+19dB'
+        assert data['spider_id'] == 'LWE'
+        assert data['gps_status'] == '3D'
 
     def test_parse_protocol_specific_fail(self):
         with pytest.raises(exceptions.ParseError):
-            parser.Spot._parse_protocol_specific('id0-2860357 SPOT3')
+            parser.Spider._parse_protocol_specific('id300234010617040 +19dB')
 
 
 class TestServerParser: