Open-ET / flux-data-qaqc

Energy Balance Closure Analysis and Eddy Flux Data Post-Processing
BSD 3-Clause "New" or "Revised" License
25 stars 13 forks source link

Low code coverage #10

Closed ashwinvis closed 3 years ago

ashwinvis commented 3 years ago

If I run

❯ pytest --cov=fluxdataqaqc tests/
==================================== test session starts ====================================
platform linux -- Python 3.8.9, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/avmo/src/sandbox/flux-data-qaqc, configfile: pytest.ini
plugins: cov-2.12.1, nbval-0.9.6
collected 11 items                                                                          

tests/test_fluxdataqaqc.py ...........                                                [100%]

----------- coverage: platform linux, python 3.8.9-final-0 -----------
Name                       Stmts   Miss  Cover
----------------------------------------------
fluxdataqaqc/__init__.py       8      0   100%
fluxdataqaqc/data.py         488    114    77%
fluxdataqaqc/plot.py         552    290    47%
fluxdataqaqc/qaqc.py         663    619     7%
fluxdataqaqc/util.py          90     60    33%
----------------------------------------------
TOTAL                       1801   1083    40%

==================================== 11 passed in 21.02s ====================================

I notice that the tests mostly target only the data module. If the tutorials cover the rest then it should be good enough and one could check the coverage as follows.

❯ cd examples/Basic_usage
❯ pytest --cov=fluxdataqaqc --nbval Tutorial.ipynb ../../tests/

However, in order to do that, #9 should be fixed first.

ashwinvis commented 3 years ago

The code coverage is up to 72% if we include the tutorial. Of course this is not an automated unit test and there is room for improvement. For the purpose of this review (https://github.com/openjournals/joss-reviews/issues/3418) this is satisfactory.

You could pursue this further in the future @JohnVolk.

ashwinvis commented 3 years ago

Note: Bokeh causes outputs to change, so I used the --nbval-lax instead.

pytest --cov=fluxdataqaqc --cov-report=html --nbval-lax -v Tutorial.ipynb ../../tests/
JohnVolk commented 3 years ago

Thanks for the info @ashwinvis I wasn't aware of this plugin and the options, it is really useful. I was also having issues with the --cov option on the notebooks. Yes, I plan on flushing out the automated tests.

ashwinvis commented 3 years ago

I used the plugins pytest-cov (coverage) and nbval (notebook testing), as you might have figured out already.