From 93db7c460bc189ecbe3bfb409d39d766bdd9500a Mon Sep 17 00:00:00 2001 From: Lindsay Gaines Date: Mon, 14 Oct 2024 15:31:05 +1100 Subject: [PATCH] Add small domain test 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. --- .github/workflows/build_docker.yaml | 2 +- tests/integration/test_domain.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/integration/test_domain.py diff --git a/.github/workflows/build_docker.yaml b/.github/workflows/build_docker.yaml index 5cffcb9..f0e7b1d 100644 --- a/.github/workflows/build_docker.yaml +++ b/.github/workflows/build_docker.yaml @@ -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 diff --git a/tests/integration/test_domain.py b/tests/integration/test_domain.py new file mode 100644 index 0000000..3c2b1f9 --- /dev/null +++ b/tests/integration/test_domain.py @@ -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) + + \ No newline at end of file