Unit/functional tests for ehratm

The unit tests are in the unit/ directory, run by the pytest routine. The functional tests, those that illustrate component usage from data prep to data output, are in the func/ directory, and are also run with the pytest routine.

The test data for all of these tests are in subdirectories of the tests, currently containing about 1.1 GB of files (most of it for the func tests)..

To set up the environment for these tests, edit setup_test_env.sh for system-specific paths, and then load the environment variables by sourcing

$ . setup_test_env.sh

WARNING - ALSO NEED TO CHANGE VALUES IN syspaths.py FOR NOW

Unit tests

These tests focus on the individual ehratm components for WRF, WPS and Flexpart WRF and test basic functionality of a component’s interface and checking of arguments. They don’t really test the component’s functionality.

$ pytest unit
============================= 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/ehratm/tests
plugins: anyio-2.2.0
collected 45 items

unit/test_flexwrf_flexwrf.py .......                                     [ 15%]
unit/test_postproc_srm.py ......                                         [ 28%]
unit/test_wps_ecmwfplevels.py ....                                       [ 37%]
unit/test_wps_geogrid.py ...                                             [ 44%]
unit/test_wps_metgrid.py ......                                          [ 57%]
unit/test_wps_ungrib.py .....                                            [ 68%]
unit/test_wrf_real.py .......                                            [ 84%]
unit/test_wrf_wrf.py .......                                             [100%]

============================== 45 passed in 0.17s ==============================

Functional tests

These test the component for a small functional example. Most of them are relatively quick, but the flexwrf and wrf components can add some substantial time. The following shows the invocation of both unit and func tests. The func tests can, of course, be run separately (pytest func), and tests may be run individually by file, or even individual tests within a file. Through use of the -s flag, logger output will go to stdout for troubleshooting and development purposes.

$ pytest
============================= 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/ehratm/tests
plugins: anyio-2.2.0
collected 65 items

func/test_func_flexwrf_flexwrf.py ..                                     [  3%]
func/test_func_postproc_srm.py .                                         [  4%]
func/test_func_wps_ecmwfplevels.py .                                     [  6%]
func/test_func_wps_geogrid.py .....                                      [ 13%]
func/test_func_wps_metgrid.py ....                                       [ 20%]
func/test_func_wps_ungrib.py ...                                         [ 24%]
func/test_func_wrf_real.py ..                                            [ 27%]
func/test_func_wrf_wrf.py ..                                             [ 30%]
unit/test_flexwrf_flexwrf.py .......                                     [ 41%]
unit/test_postproc_srm.py ......                                         [ 50%]
unit/test_wps_ecmwfplevels.py ....                                       [ 56%]
unit/test_wps_geogrid.py ...                                             [ 61%]
unit/test_wps_metgrid.py ......                                          [ 70%]
unit/test_wps_ungrib.py .....                                            [ 78%]
unit/test_wrf_real.py .......                                            [ 89%]
unit/test_wrf_wrf.py .......                                             [100%]

======================== 65 passed in 263.34s (0:04:23) ========================