1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
import unittest
from aprslib.parsing import parse_position
class ParsePositionDataExtAndWeather(unittest.TestCase):
def setUp(self):
self.maxDiff = None
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,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
def test_position_packet_data_ext_and_weather_valid(self):
packet_type = '@'
packet = "092345z4903.50N/07201.75W_090/001g000t066r000p000...dUII"
expected = {
'messagecapable': True,
'raw_timestamp': '092345z',
'timestamp': 1657410300,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'course': 90,
'speed': 1*1.852,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
def test_position_packet_optional_speed(self):
packet_type = '@'
packet = "092345z4903.50N/07201.75W_090/...g000t066r000p000...dUII"
expected = {
'messagecapable': True,
'raw_timestamp': '092345z',
'timestamp': 1657410300,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'course': 90,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
def test_position_packet_optional_course(self):
packet_type = '@'
packet = "092345z4903.50N/07201.75W_ /001g000t066r000p000...dUII"
expected = {
'messagecapable': True,
'raw_timestamp': '092345z',
'timestamp': 1657410300,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'speed': 1*1.852,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
def test_position_packet_optional_speed_and_course(self):
packet_type = '@'
packet = "092345z4903.50N/07201.75W_.../...g000t066r000p000...dUII"
expected = {
'messagecapable': True,
'raw_timestamp': '092345z',
'timestamp': 1657410300,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
def test_position_packet_optional_course(self):
packet_type = '@'
packet = "092345z4903.50N/07201.75W_ /001g000t066r000p000...dUII"
expected = {
'messagecapable': True,
'raw_timestamp': '092345z',
'timestamp': 1657410300,
'format': 'uncompressed',
'posambiguity': 0,
'symbol': '_',
'symbol_table': '/',
'latitude': 49.05833333333333,
'longitude': -72.02916666666667,
'speed': 1*1.852,
'comment': '...dUII',
'weather': {
'wind_gust': 0.0,
'temperature': 18.88888888888889,
'rain_1h': 0.0,
'rain_24h': 0.0
}
}
_, result = parse_position(packet_type, packet)
self.assertEqual(expected, result)
if __name__ == '__main__':
unittest.main()
|