Skip to content

Commit 437777a

Browse files
committed
Add small test suite; check output of CSV files
1 parent eff3190 commit 437777a

6 files changed

Lines changed: 64 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ python GA_Detect.py # does the same thing as the next command:
8484
python GA_Detect.py \
8585
--top-dir=. --metars-file=VABB_METAR --airport=VABB
8686
```
87+
88+
## Running tests
89+
90+
To run the included test suite, first install pytest via `pip install
91+
pytest` and then run `pytest -s tests`.
4.17 MB
Binary file not shown.

tests/data/VABB_METAR

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VABB,2019-08-10 00:00,VABB 100000Z 23010G20KT 2500 HZ SCT018 FEW025TCU BKN090 28/25 Q1000 NOSIG
2+
VABB,2019-08-10 00:30,VABB 100030Z 24010G20KT 2500 HZ SCT018 FEW025TCU BKN090 28/25 Q1000 TEMPO 1500 RA
3+
VABB,2019-08-10 01:00,VABB 100100Z 25011G21KT 2500 HZ SCT012 SCT018 BKN090 28/25 Q1000 TEMPO 1500 RA
4+
VABB,2019-08-10 01:30,VABB 100130Z 24014G24KT 2500 HZ FEW012 SCT018 BKN090 28/25 Q1001 NOSIG
5+
VABB,2019-08-10 02:00,VABB 100200Z 24009G19KT 2500 HZ FEW012 SCT018 BKN090 28/26 Q1001 NOSIG

tests/data/expected/GA_MET_NEW.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ICAO24, Callsign, GA_Time, L_Time, Runway, Heading, Alt, Lat, Lon, gapt, rocvar, hdgvar, latvar, lonvar, gspvar, Temp, Dewp, Wind_Spd, Wind_Gust, Wind_Dir,Cld_Base, CB, Vis, Pressure
2+
04c147,KQA204,2019/08/10 00:21:24,2019/08/10 00:19:25,27,263.9909940425055,1347.6201812316162,19.08824157714844,72.8559820992606,370,1.3554425701202464,0.0027863795136474465,3.5391823044835526e-06,0.00021195186832100995,0.03189928263824995,28.0,25.0,10.0,20.0,240.0,1800.0,0,2500.0,1000.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ICAO24, Callsign, GA_Time, L_Time, Runway, gapt, rocvar, hdgvar, latvar, lonvar, gspvar, Temp, Dewp, Wind_Spd, Wind_Gust, Wind_Dir,Cld_Base, CB, Vis, Pressure
2+
8005ee,AIC317,2019/08/10 00:26:12,2019/08/10 00:16:54,27,0,1.5964404850235485,0.0006783574870077095,2.4668402388350134e-06,0.0001930544997218994,0.11175369742826806,28.0,25.0,10.0,20.0,240.0,1800.0,0,2500.0,1000.0
3+
800732,AIC124,2019/08/10 00:05:45,2019/08/10 00:00:01,27,0,1.4635712542703654,0.009514184629520878,2.7480109772978474e-06,0.00019246633015406858,0.026726124191242435,28.0,25.0,10.0,20.0,230.0,1800.0,0,2500.0,1000.0
4+
800bb6,IGO218,2019/08/10 00:45:44,2019/08/10 00:38:25,27,0,0.7520124217363429,0.00612862439723081,2.324620750136083e-06,0.00016878190829216932,0.04790138895453693,28.0,25.0,11.0,21.0,250.0,1200.0,0,2500.0,1000.0
5+
800c69,GOW030,2019/08/10 00:08:06,2019/08/10 00:00:01,27,0,0.8958133916464194,0.00029074779492562153,2.0333079803969063e-06,0.0001726147052984897,0.036253078686998626,28.0,25.0,10.0,20.0,230.0,1800.0,0,2500.0,1000.0
6+
800c71,IGO456,2019/08/10 00:48:02,2019/08/10 00:41:43,27,0,0.950105112352263,0.011971063410794125,2.681003129011264e-06,0.00020661348328495407,0.09270944570168702,28.0,25.0,11.0,21.0,250.0,1200.0,0,2500.0,1000.0
7+
800dac,IGO235,2019/08/10 00:32:31,2019/08/10 00:24:02,27,0,0.8887419529611325,0.01015078239663644,2.1995557883975666e-06,0.00015366319326703428,0.05454545454545455,28.0,25.0,10.0,20.0,240.0,1800.0,0,2500.0,1000.0

tests/test_GA_detect.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os
2+
import shutil
3+
import sys
4+
5+
from click.testing import CliRunner
6+
import pytest
7+
8+
sys.path.insert(0, '.')
9+
10+
11+
@pytest.fixture
12+
def data_dir():
13+
return os.path.join(os.path.dirname(__file__), 'data')
14+
15+
16+
@pytest.fixture
17+
def data_dir_copy(data_dir, tmpdir):
18+
dest = str(tmpdir) + '/' + os.path.basename(data_dir)
19+
shutil.copytree(data_dir, dest)
20+
return dest
21+
22+
23+
class TestMain:
24+
@pytest.fixture
25+
def vabb(self, data_dir_copy):
26+
from GA_Detect import main
27+
runner = CliRunner()
28+
result = runner.invoke(main, [
29+
'--top-dir', data_dir_copy + '/',
30+
'--metars-file', os.path.join(data_dir_copy, 'VABB_METAR'),
31+
'--pool-proc', '1',
32+
'--no-plot',
33+
])
34+
if result.exception:
35+
raise result.exception
36+
assert result.exit_code == 0
37+
return result
38+
39+
def test_csv(self, vabb, data_dir, data_dir_copy):
40+
for fname in ['GA_MET_NEW.csv', 'GA_NOGA_NEW.csv']:
41+
with open(os.path.join(data_dir, 'expected', fname)) as f:
42+
csv_expected = f.read()
43+
with open(os.path.join(data_dir_copy, fname)) as f:
44+
csv_got = f.read()
45+
assert csv_expected == csv_got

0 commit comments

Comments
 (0)