/
test_aircraft.py
44 lines (32 loc) · 1.34 KB
/
test_aircraft.py
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
import pytest
from traffic.data import aircraft
def test_getter() -> None:
a = aircraft["PH-BHA"]
assert a.icao24.iloc[0] == "4851ad"
assert a.typecode.iloc[0] == "B789"
a = aircraft["39b415"]
assert a.registration.iloc[0] == "F-HNAV"
assert a.typecode.iloc[0] == "BE20"
@pytest.mark.skipif(aircraft.opensky_db is not None, reason="OpenSky database")
def test_opensky_dl() -> None:
aircraft.download_opensky()
assert aircraft.opensky_db is not None
@pytest.mark.skipif(aircraft.opensky_db is None, reason="OpenSky database")
def test_operator() -> None:
df = aircraft.operator("penguin")
assert df.operator.iloc[0] == "British Antarctic Survey"
assert df.operatoricao.iloc[0] == "BAN"
assert df.registration.str.startswith("VP-F").all()
@pytest.mark.skipif(aircraft.opensky_db is None, reason="OpenSky database")
def test_stats() -> None:
df = aircraft.stats("speedbird")
# well let's say they must be enough...
assert df.shape[0] > 10
assert df.icao24.sum() > 200
def test_query() -> None:
df = aircraft.query(operator="KLM", model="b789")
assert (df.typecode == "B789").all()
assert df.registration.str.startswith("PH-").all()
df = aircraft.query(registration="^F-ZB", model="S2P")
assert (df.typecode == "S2P").all()
assert df.registration.str.startswith("F-ZB").all()