Skip to content

Commit c2a0f18

Browse files
fix timestamp in test_parse_position
1 parent ef88e34 commit c2a0f18

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
*.pyc
44
dist
55
*.egg-info
6+
env3
7+
env2

tests/test_parse_position.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import unittest
2+
from datetime import datetime
23

34
from aprslib.parsing import parse_position
45

56
class ParsePositionDataExtAndWeather(unittest.TestCase):
67
def setUp(self):
78
self.maxDiff = None
89

10+
def timestamp_from_partial(self, day, hour, minute):
11+
now = datetime.now()
12+
corrected = now.replace(day=day, hour=hour, minute=minute, second=0, microsecond=0)
13+
return int((corrected - datetime(1970, 1, 1)).total_seconds())
14+
915
def test_position_packet_only_weather_valid(self):
1016
packet_type = '@'
1117
packet = "092345z4903.50N/07201.75W_g000t066r000p000...dUII"
1218
expected = {
1319
'messagecapable': True,
1420
'raw_timestamp': '092345z',
15-
'timestamp': 1657410300,
21+
'timestamp': self.timestamp_from_partial(9, 23, 45),
1622
'format': 'uncompressed',
1723
'posambiguity': 0,
1824
'symbol': '_',
@@ -37,7 +43,7 @@ def test_position_packet_data_ext_and_weather_valid(self):
3743
expected = {
3844
'messagecapable': True,
3945
'raw_timestamp': '092345z',
40-
'timestamp': 1657410300,
46+
'timestamp': self.timestamp_from_partial(9, 23, 45),
4147
'format': 'uncompressed',
4248
'posambiguity': 0,
4349
'symbol': '_',
@@ -64,7 +70,7 @@ def test_position_packet_optional_speed(self):
6470
expected = {
6571
'messagecapable': True,
6672
'raw_timestamp': '092345z',
67-
'timestamp': 1657410300,
73+
'timestamp': self.timestamp_from_partial(9, 23, 45),
6874
'format': 'uncompressed',
6975
'posambiguity': 0,
7076
'symbol': '_',
@@ -90,7 +96,7 @@ def test_position_packet_optional_course(self):
9096
expected = {
9197
'messagecapable': True,
9298
'raw_timestamp': '092345z',
93-
'timestamp': 1657410300,
99+
'timestamp': self.timestamp_from_partial(9, 23, 45),
94100
'format': 'uncompressed',
95101
'posambiguity': 0,
96102
'symbol': '_',
@@ -116,7 +122,7 @@ def test_position_packet_optional_speed_and_course(self):
116122
expected = {
117123
'messagecapable': True,
118124
'raw_timestamp': '092345z',
119-
'timestamp': 1657410300,
125+
'timestamp': self.timestamp_from_partial(9, 23, 45),
120126
'format': 'uncompressed',
121127
'posambiguity': 0,
122128
'symbol': '_',
@@ -140,7 +146,7 @@ def test_position_packet_optional_course(self):
140146
expected = {
141147
'messagecapable': True,
142148
'raw_timestamp': '092345z',
143-
'timestamp': 1657410300,
149+
'timestamp': self.timestamp_from_partial(9, 23, 45),
144150
'format': 'uncompressed',
145151
'posambiguity': 0,
146152
'symbol': '_',

0 commit comments

Comments
 (0)