Unit/Functional Tests
The nwpservice package components all have unit tests associated with them. Technically, they are functional tests, but are invoked through the unit-testing mechanism.
To run them, in the packages/nwpservice/tests/
directory, note the sys_specific_test_env.sh
environment file and ensure it is set up for your system. Currently, it is set up correctly for either the EHRATM VM or the CTBTO devlan environment, but would need to be modified for a particular user. The primary environment file, setup_test_components_env.sh
imports the system-specific environment variables, and is then run before the unit tests as follows
$ . setup_test_components_env.sh
$ pytest test_components
============================= test session starts ==============================
platform linux -- Python 3.8.8, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: /home/ctbtuser/git/high-res-atm/packages/nwpservice/tests
plugins: anyio-2.2.0
collected 36 items
test_components/test_calcecmwfp/test_calcecmwfp_component.py . [ 2%]
test_components/test_flexwrf/test_flexwrf_component.py .... [ 13%]
test_components/test_geogrid/test_geogrid_component.py .. [ 19%]
test_components/test_metgrid/test_metgrid_component.py ... [ 27%]
test_components/test_namelistwps/test_namelistwps.py ........... [ 58%]
test_components/test_real/test_real_component.py .... [ 69%]
test_components/test_ungrib/test_ungrib_component.py .... [ 80%]
test_components/test_wps_vizutils/test_vizutils.py ... [ 88%]
test_components/test_wrf/test_wrf_component.py .... [100%]
======================== 36 passed in 578.80s (0:09:38) ========================
It is possible (and often advisable) to run any of the files alone, and it’s even possible to run a specific test within a file. This is particularly useful when debugging a problem or testing new code. Also, use of the -s
flag when running pytest
will send the logging output (of which there is a LOT) to stdout.