def test_zero_alt(self): self.assertEqual( msg_item_to_point([1990, 1528548291.011041, 1, '(864768011199962,DW3B,050316,A,2754.4558S,02759.0423E,6.82,124449,279.65,0,10,0)', 'TK05']), { 'tk_id': 'TK05', 'num_sat': 10, 'position': (-27.907596666666667, 27.984038333333334), 'server_time': datetime.datetime(2018, 6, 9, 14, 44, 51, 11041), 'time': datetime.datetime(2018, 6, 9, 14, 44, 49), # NOQA }, )
def test_pos2(self): self.assertEqual( msg_item_to_point([0, 1526394347, 1, '(864768011468102,DW30,080618,A,2752.87996S,02755.19665E,1.910,202919,000.0,1538.20,12,0)', 'TK01']), { 'tk_id': 'TK01', 'num_sat': 12, 'position': (-27.881332666666665, 27.919944166666667, 1538.2), 'server_time': datetime.datetime(2018, 5, 15, 16, 25, 47), 'time': datetime.datetime(2018, 6, 8, 22, 29, 19), }, )
def test_pos1(self): self.assertEqual( msg_item_to_point([0, 1526394347, 1, '(864768011193965,DW30,150518,A,2605.6699S,02756.5543E,0.20,142539,0.00,1604.20,12)', 'TK01']), { 'tk_id': 'TK01', 'num_sat': 12, 'position': (-26.094498333333334, 27.942571666666666, 1604.2), 'server_time': datetime.datetime(2018, 5, 15, 16, 25, 47), 'time': datetime.datetime(2018, 5, 15, 16, 25, 39), }, )
def test_battery(self): self.assertEqual( msg_item_to_point([1, 1525366678, 1, '(864768011199921,ZC20,030518,165713,6,402,65535,255)', 'TK00']), { 'tk_id': 'TK00', 'server_time': datetime.datetime(2018, 5, 3, 18, 57, 58), 'time': datetime.datetime(2018, 5, 3, 18, 57, 13), 'battery': 82.66666666666674, 'battery_voltage': 4.0200000000000005, }, )
def test_missing_date_before(self): server_time = datetime.datetime(2018, 6, 9, 23, 58, 00) self.assertEqual( msg_item_to_point([1990, server_time.timestamp(), 1, '(864768011468169,DW3B,000000,A,3124.00405S,02355.82419E,9.061,215900,190.21,1273.30,11,0)', 'TK05']), { 'num_sat': 11, 'position': (-31.4000675, 23.930403166666668, 1273.3), 'server_time': datetime.datetime(2018, 6, 9, 23, 58), 'time': datetime.datetime(2018, 6, 9, 23, 59), 'tk_id': 'TK05', }, )
def test_ZC03_msg(self): def stub_ZC03_parse(msg): yield 'foo', 'bar' with unittest.mock.patch('trackers.sources.tkstorage.ZC03_parse', stub_ZC03_parse): self.assertEqual( msg_item_to_point([0, 1526394226, 1, '(864768011193965,ZC03,150518,142343,$stuff$)', 'TK01']), {'server_time': datetime.datetime(2018, 5, 15, 16, 23, 46), 'tk_id': 'TK01', 'time': datetime.datetime(2018, 5, 15, 16, 23, 43), 'foo': 'bar', }, )
def test_connect(self): self.assertEqual( msg_item_to_point([0, 1525366636, 0, [b'::1', 60652, 0, 0], None]), None, )