From 0adad7794fe7499dbbe9047c65d076ccda0b08ac Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Fri, 12 Dec 2014 05:23:55 +0000 Subject: [PATCH] fix bug with 'via' not being set --- aprs/parse.py | 2 +- aprs/version.py | 2 +- tests/test_parse_header.py | 25 +++++++++++++++++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/aprs/parse.py b/aprs/parse.py index 3acbbc4..2fe08c5 100644 --- a/aprs/parse.py +++ b/aprs/parse.py @@ -684,7 +684,7 @@ def _parse_header(head): # .....................|-via-| # viacall = "" - if len(path) > 2 and re.match(r"^q..$", path[-2]): + if len(path) >= 2 and re.match(r"^q..$", path[-2]): viacall = path[-1] parsed.update({'via': viacall}) diff --git a/aprs/version.py b/aprs/version.py index 70039a4..cf3afd5 100644 --- a/aprs/version.py +++ b/aprs/version.py @@ -1 +1 @@ -__version__ = '0.6.13' +__version__ = '0.6.14' diff --git a/tests/test_parse_header.py b/tests/test_parse_header.py index 5ecc93e..29a5d73 100644 --- a/tests/test_parse_header.py +++ b/tests/test_parse_header.py @@ -51,8 +51,8 @@ class ParseHeader(unittest.TestCase): def test_valid_input_and_format(self): # empty path header expected = { - "to": "B", "from": "A", + "to": "B", "via": "", "path": [] } @@ -62,8 +62,8 @@ class ParseHeader(unittest.TestCase): # with path expected2 = { - "to": "B", "from": "A", + "to": "B", "via": "", "path": list('CDE') } @@ -72,17 +72,26 @@ class ParseHeader(unittest.TestCase): self.assertEqual(expected2, result2) # test all currently valid q-cosntructs + expected3 = { + "from": "A", + "to": "B", + "via": "E", + "path": ['C', 'D', 'qAR', 'E'] + } + result3 = _parse_header("A>B,C,D,qAR,E") + + self.assertEqual(expected3, result3) for qCon in map(lambda x: "qA"+x, list("CXUoOSrRRZI")): - expected3 = { - "to": "B", + expected4 = { "from": "A", - "via": "D", - "path": ['C', qCon, 'D'] + "to": "B", + "via": "C", + "path": [qCon, 'C'] } - result3 = _parse_header("A>B,C,%s,D" % qCon) + result4 = _parse_header("A>B,%s,C" % qCon) - self.assertEqual(expected3, result3) + self.assertEqual(expected4, result4) def test_invalid_format(self): testData = [