Skip to content

Commit

Permalink
Add small domain test
Browse files Browse the repository at this point in the history
This simple test can replace the removed test_domain_json as it tests many of the same things, just without the intermediate step of converting it to JSON.
  • Loading branch information
aethr committed Oct 14, 2024
1 parent b41b2a7 commit 93db7c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
run: |
cd /opt/project
cp .env.example .env
python -m pytest -r a -v tests/integration/test_domain_json.py
python -m pytest -r a -v tests/integration/test_domain.py
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_ADS_KEY }}
CDSAPI_URL: https://ads.atmosphere.copernicus.eu/api
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/test_domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import numpy

def test_domain_attributes(input_domain):
# Check domain matches projection used in calculations
assert type(input_domain.attrs["TRUELAT1"]) == numpy.float32
assert type(input_domain.attrs["TRUELAT2"]) == numpy.float32
assert type(input_domain.attrs["MOAD_CEN_LAT"]) == numpy.float32
assert type(input_domain.attrs["STAND_LON"]) == numpy.float32
assert type(input_domain.attrs["XCENT"]) == numpy.float64
assert type(input_domain.attrs["YCENT"]) == numpy.float64

assert type(input_domain.attrs['DX']) == numpy.float32
assert input_domain.attrs['DX'] > 0
assert type(input_domain.attrs['DX']) == numpy.float32
assert input_domain.attrs['DY'] > 0

# Check domain matches projection used in calculations
def test_domain_projection(config, input_domain):
assert str(input_domain.attrs["TRUELAT1"]) in str(config.crs)
assert str(input_domain.attrs["TRUELAT2"]) in str(config.crs)
assert str(input_domain.attrs["MOAD_CEN_LAT"]) in str(config.crs)
assert str(input_domain.attrs["STAND_LON"]) in str(config.crs)
assert str(input_domain.attrs["XCENT"]) in str(config.crs)
# TODO: is this a problem?
# assert str(input_domain.attrs["YCENT"]) in str(config.crs)


0 comments on commit 93db7c4

Please sign in to comment.