major update; adsb restructure; rename combining util/modes to common.
This commit is contained in:
@@ -58,8 +58,8 @@ def test_adsb_velocity():
|
||||
vgs = adsb.velocity("8D485020994409940838175B284F")
|
||||
vas = adsb.velocity("8DA05F219B06B6AF189400CBC33F")
|
||||
vgs_surface = adsb.velocity("8FC8200A3AB8F5F893096B000000")
|
||||
assert vgs == (159, 182.9, -832, 'GS')
|
||||
assert vas == (376, 244.0, -2304, 'AS')
|
||||
assert vgs == (159, 182.88, -832, 'GS')
|
||||
assert vas == (375, 243.98, -2304, 'TAS')
|
||||
assert vgs_surface == (19.0, 42.2, 0 , 'GS')
|
||||
assert adsb.altitude_diff('8D485020994409940838175B284F') == 550
|
||||
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
from pyModeS import bds, modes
|
||||
|
||||
def test_ehs_icao():
|
||||
assert modes.icao("A0001839CA3800315800007448D9") == '400940'
|
||||
assert modes.icao("A000139381951536E024D4CCF6B5") == '3C4DD2'
|
||||
assert modes.icao("A000029CFFBAA11E2004727281F1") == '4243D0'
|
||||
|
||||
|
||||
def test_modes_altcode():
|
||||
assert modes.altcode("A02014B400000000000000F9D514") == 32300
|
||||
|
||||
def test_modes_idcode():
|
||||
assert modes.idcode("A800292DFFBBA9383FFCEB903D01") == '1346'
|
||||
|
||||
from pyModeS import bds, ehs, els
|
||||
|
||||
def test_bds_infer():
|
||||
assert bds.infer("A0001838201584F23468207CDFA5") == 'BDS20'
|
||||
@@ -25,13 +12,18 @@ def test_bds_is50or60():
|
||||
assert bds.is50or60("A0000000919A5927E23444000000", 413, 54, 18700) == 'BDS60'
|
||||
|
||||
def test_els_BDS20_callsign():
|
||||
assert bds.bds20.callsign("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
|
||||
assert bds.bds20.callsign("A0001993202422F2E37CE038738E") == 'IBK2873_'
|
||||
assert bds.bds20.cs20("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
|
||||
assert bds.bds20.cs20("A0001993202422F2E37CE038738E") == 'IBK2873_'
|
||||
assert els.cs20("A000083E202CC371C31DE0AA1CCF") == 'KLM1017_'
|
||||
assert els.cs20("A0001993202422F2E37CE038738E") == 'IBK2873_'
|
||||
|
||||
def test_ehs_BDS40_functions():
|
||||
assert bds.bds40.alt40mcp("A000029C85E42F313000007047D3") == 3008
|
||||
assert bds.bds40.alt40fms("A000029C85E42F313000007047D3") == 3008
|
||||
assert bds.bds40.p40baro("A000029C85E42F313000007047D3") == 1020.0
|
||||
assert ehs.alt40mcp("A000029C85E42F313000007047D3") == 3008
|
||||
assert ehs.alt40fms("A000029C85E42F313000007047D3") == 3008
|
||||
assert ehs.p40baro("A000029C85E42F313000007047D3") == 1020.0
|
||||
|
||||
def test_ehs_BDS50_functions():
|
||||
assert bds.bds50.roll50("A000139381951536E024D4CCF6B5") == 2.1
|
||||
@@ -40,6 +32,12 @@ def test_ehs_BDS50_functions():
|
||||
assert bds.bds50.gs50("A000139381951536E024D4CCF6B5") == 438
|
||||
assert bds.bds50.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
|
||||
assert bds.bds50.tas50("A000139381951536E024D4CCF6B5") == 424
|
||||
assert ehs.roll50("A000139381951536E024D4CCF6B5") == 2.1
|
||||
assert ehs.roll50("A0001691FFD263377FFCE02B2BF9") == -0.4 # signed value
|
||||
assert ehs.trk50("A000139381951536E024D4CCF6B5") == 114.258
|
||||
assert ehs.gs50("A000139381951536E024D4CCF6B5") == 438
|
||||
assert ehs.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
|
||||
assert ehs.tas50("A000139381951536E024D4CCF6B5") == 424
|
||||
|
||||
def test_ehs_BDS60_functions():
|
||||
assert bds.bds60.hdg60("A00004128F39F91A7E27C46ADC21") == 42.715
|
||||
@@ -47,20 +45,8 @@ def test_ehs_BDS60_functions():
|
||||
assert bds.bds60.mach60("A00004128F39F91A7E27C46ADC21") == 0.42
|
||||
assert bds.bds60.vr60baro("A00004128F39F91A7E27C46ADC21") == -1920
|
||||
assert bds.bds60.vr60ins("A00004128F39F91A7E27C46ADC21") == -1920
|
||||
|
||||
def test_graycode_to_altitude():
|
||||
assert modes.gray2alt('00000000010') == -1000
|
||||
assert modes.gray2alt('00000001010') == -500
|
||||
assert modes.gray2alt('00000011011') == -100
|
||||
assert modes.gray2alt('00000011010') == 0
|
||||
assert modes.gray2alt('00000011110') == 100
|
||||
assert modes.gray2alt('00000010011') == 600
|
||||
assert modes.gray2alt('00000110010') == 1000
|
||||
assert modes.gray2alt('00001001001') == 5800
|
||||
assert modes.gray2alt('00011100100') == 10300
|
||||
assert modes.gray2alt('01100011010') == 32000
|
||||
assert modes.gray2alt('01110000100') == 46300
|
||||
assert modes.gray2alt('01010101100') == 50200
|
||||
assert modes.gray2alt('11011110100') == 73200
|
||||
assert modes.gray2alt('10000000011') == 126600
|
||||
assert modes.gray2alt('10000000001') == 126700
|
||||
assert ehs.hdg60("A00004128F39F91A7E27C46ADC21") == 42.715
|
||||
assert ehs.ias60("A00004128F39F91A7E27C46ADC21") == 252
|
||||
assert ehs.mach60("A00004128F39F91A7E27C46ADC21") == 0.42
|
||||
assert ehs.vr60baro("A00004128F39F91A7E27C46ADC21") == -1920
|
||||
assert ehs.vr60ins("A00004128F39F91A7E27C46ADC21") == -1920
|
||||
42
tests/test_common.py
Normal file
42
tests/test_common.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from pyModeS import common
|
||||
|
||||
|
||||
def test_hex2bin():
|
||||
assert common.hex2bin('6E406B') == "011011100100000001101011"
|
||||
|
||||
def test_crc_decode():
|
||||
checksum = common.crc("8D406B902015A678D4D220AA4BDA")
|
||||
assert checksum == "000000000000000000000000"
|
||||
|
||||
def test_crc_encode():
|
||||
parity = common.crc("8D406B902015A678D4D220AA4BDA", encode=True)
|
||||
assert common.hex2bin("AA4BDA") == parity
|
||||
|
||||
def test_icao():
|
||||
assert common.icao("8D406B902015A678D4D220AA4BDA") == "406B90"
|
||||
assert common.icao("A0001839CA3800315800007448D9") == '400940'
|
||||
assert common.icao("A000139381951536E024D4CCF6B5") == '3C4DD2'
|
||||
assert common.icao("A000029CFFBAA11E2004727281F1") == '4243D0'
|
||||
|
||||
def test_modes_altcode():
|
||||
assert common.altcode("A02014B400000000000000F9D514") == 32300
|
||||
|
||||
def test_modes_idcode():
|
||||
assert common.idcode("A800292DFFBBA9383FFCEB903D01") == '1346'
|
||||
|
||||
def test_graycode_to_altitude():
|
||||
assert common.gray2alt('00000000010') == -1000
|
||||
assert common.gray2alt('00000001010') == -500
|
||||
assert common.gray2alt('00000011011') == -100
|
||||
assert common.gray2alt('00000011010') == 0
|
||||
assert common.gray2alt('00000011110') == 100
|
||||
assert common.gray2alt('00000010011') == 600
|
||||
assert common.gray2alt('00000110010') == 1000
|
||||
assert common.gray2alt('00001001001') == 5800
|
||||
assert common.gray2alt('00011100100') == 10300
|
||||
assert common.gray2alt('01100011010') == 32000
|
||||
assert common.gray2alt('01110000100') == 46300
|
||||
assert common.gray2alt('01010101100') == 50200
|
||||
assert common.gray2alt('11011110100') == 73200
|
||||
assert common.gray2alt('10000000011') == 126600
|
||||
assert common.gray2alt('10000000001') == 126700
|
||||
@@ -1,15 +0,0 @@
|
||||
from pyModeS import util
|
||||
|
||||
|
||||
def test_hex2bin():
|
||||
assert util.hex2bin('6E406B') == "011011100100000001101011"
|
||||
|
||||
|
||||
def test_crc_decode():
|
||||
checksum = util.crc("8D406B902015A678D4D220AA4BDA")
|
||||
assert checksum == "000000000000000000000000"
|
||||
|
||||
|
||||
def test_crc_encode():
|
||||
parity = util.crc("8D406B902015A678D4D220AA4BDA", encode=True)
|
||||
assert util.hex2bin("AA4BDA") == parity
|
||||
Reference in New Issue
Block a user