diff --git a/.gitignore b/.gitignore index 6b6abd0..8e10410 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ *.pyc dist *.egg-info +env3 +env2 diff --git a/tests/test_parse_position.py b/tests/test_parse_position.py index 345ea8b..4a2287b 100644 --- a/tests/test_parse_position.py +++ b/tests/test_parse_position.py @@ -1,4 +1,5 @@ import unittest +from datetime import datetime from aprslib.parsing import parse_position @@ -6,13 +7,18 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): def setUp(self): self.maxDiff = None + def timestamp_from_partial(self, day, hour, minute): + now = datetime.now() + corrected = now.replace(day=day, hour=hour, minute=minute, second=0, microsecond=0) + return int((corrected - datetime(1970, 1, 1)).total_seconds()) + def test_position_packet_only_weather_valid(self): packet_type = '@' packet = "092345z4903.50N/07201.75W_g000t066r000p000...dUII" expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_', @@ -37,7 +43,7 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_', @@ -64,7 +70,7 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_', @@ -90,7 +96,7 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_', @@ -116,7 +122,7 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_', @@ -140,7 +146,7 @@ class ParsePositionDataExtAndWeather(unittest.TestCase): expected = { 'messagecapable': True, 'raw_timestamp': '092345z', - 'timestamp': 1657410300, + 'timestamp': self.timestamp_from_partial(9, 23, 45), 'format': 'uncompressed', 'posambiguity': 0, 'symbol': '_',