Improved tests for get_filter_data & cache_filters module #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is to improve the efficiency of tests I created for get_filter_data & cache_filters module (by increasing code coverage & reducing execution time). Following are the changes in their corresponding test modules:
test_get_filter_data
:get_filter_index()
fetches the complete filter index & takes > 30s, so I limited the index length by passing Wavelength_Eff parameters to it, hence time reduced to ~7s onlydata_from_svo()
is not covered, so I added a test for ittest_cache_filters
:Cache reading functions (
load_filter_index
&load_transmission_data
) are being covered completely but not the cache writing functions (download_filter_data
&update_filter_data
) since they have huge data dependencies. They are internally calling get_filter_index() (without parameters) to get entire dataset and hence it didn't seem feasible to test them directly so we were testing only the helper functions they are calling.Now in this PR I've resolved this limitation by using
pytest monkeypatch
fixture to mock that huge dependency to a very shorter one (by using wavelength range parameters). Therefore we can now actually test the main download & update functions, and their helpers functions will get implicitly tested. This has also increased coverage forcache_filters
module significantly (from ~67% to 95%)!So in this PR, you'll find some major changes in the tests for cache writing functions which has even resulted several other benefits:
Also I've included enough comments to explain the code I added, to ensure that the tests remain maintainable.