Skip to content

Commit 8ea8bce

Browse files
committed
Add some tests
1 parent c3e4b00 commit 8ea8bce

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

tests/test_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import pytest
23
import subprocess
34

@@ -62,3 +63,9 @@ def test_rprof_cli(all_cmd_rprof, tmpdir):
6263

6364
def test_time_cli(all_cmd_time, tmpdir):
6465
helper_test_cli(all_cmd_time, tmpdir)
66+
67+
68+
def test_err_cli():
69+
subp = subprocess.run('stagpy field', shell=True, capture_output=True)
70+
reg = re.compile(br'^Oops!.*\nPlease.*\n\nNoParFileError.*$')
71+
assert reg.match(subp.stderr)

tests/test_field.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
import pytest
2+
import stagpy.error
13
import stagpy.field
24
import stagpy.phyvars
35

46

7+
def test_field_unknow(step):
8+
with pytest.raises(stagpy.error.UnknownFieldVarError):
9+
step.fields['InvalidField']
10+
assert 'InvalidField' not in step.fields
11+
12+
13+
def test_field_missing(step):
14+
with pytest.raises(stagpy.error.MissingDataError):
15+
step.fields['rsc']
16+
assert 'rsc' not in step.fields
17+
18+
519
def test_valid_field_var():
620
for var in stagpy.phyvars.FIELD:
721
assert stagpy.field.valid_field_var(var)

tests/test_rprof.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
import pytest
2+
import stagpy.error
13
import stagpy.rprof
24
import stagpy.phyvars
35

46

7+
def test_no_rprof_data(sdat):
8+
with pytest.raises(stagpy.error.MissingDataError):
9+
sdat.steps[1].rprofs['Tmean']
10+
11+
12+
def test_invalid_rprof(step):
13+
with pytest.raises(stagpy.error.UnknownRprofVarError):
14+
step.rprofs['DummyVar']
15+
16+
17+
def test_rprof_bounds_if_no_rprofs(sdat):
18+
rcmb, rtot = sdat.steps[1].rprofs.bounds
19+
assert rtot > rcmb
20+
21+
522
def test_get_rprof(step):
623
prof, rad, meta = step.rprofs['Tmean']
724
assert rad is step.rprofs.centers

tests/test_stagyydata.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@ def test_geom_refs(step):
9393
assert step.geom is step.fields.geom
9494

9595

96-
def test_geom_twod(step):
96+
def test_geom(step):
9797
assert step.geom.twod
98+
assert not step.geom.threed
99+
assert not step.geom.yinyang
100+
assert step.geom.cartesian is not step.geom.spherical

0 commit comments

Comments
 (0)