Download: Fix unintentional downloading of containers in test #2434
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.
When I initially wrote the tests for the new
nf-core download --tower
functionality, there was little test coverage regarding container image detection. Therefore, I incorporated some functionality along in this line into a new testtest_download_workflow_for_tower()
.Since I felt that testing everything with a real pipeline was preferable over a dummy pipeline with just one or two nicely formatted modules, I chose rnaseq as a test subject. Since the test was never intended to actually download any of the detected images, I was not bothered about the pipeline comprising more than 30 modules.
Initially, the test also performed as intended. But already two weeks later, we decided that downloading containers by default would improve the UX of
nf-core download
. Therefore, downloading containers was no longer optional when choosing the--tower
download method.This small change had unintended side effects in the tests, because now the test would actually download the 33 containers and thus several GB of data. This bug was noticed recently by @adamrtalbot and @awgymer (Thanks!).
Back then, I was not aware that it is possible to mock objects in tests. Therefore, instead of testing a function that also performs undesirable steps, I put a similar function in the test that resembled the original function, but omitted the unwanted steps. Since then, I learnt some basic mocking capability and changed the test to mock the download function now. This should ensure that no images are actually pulled, but will inevitably decrease test coverage slightly.
Since the actual download of a container image is tested with a different test
test_singularity_pull_image_singularity_installed()
, which I have written after the Tower functionality was first added, just mocking the download intest_download_workflow_for_tower()
should be safe.PR checklist
CHANGELOG.md
is updateddocs
is updated