-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Split biocontainer and anaconda mocks
Responses actually throws an error if all the mocks aren't used. That allowed me to clean up a few tests that weren't actually using the mocks and find a few.
- Loading branch information
1 parent
5d71739
commit f65224c
Showing
3 changed files
with
33 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,47 @@ | ||
import os | ||
|
||
import pytest | ||
import responses | ||
|
||
import nf_core.modules | ||
from tests.utils import mock_api_calls | ||
|
||
|
||
def test_modules_create_succeed(self): | ||
"""Succeed at creating the TrimGalore! module""" | ||
with responses.RequestsMock() as rsps: | ||
mock_api_calls(rsps, "trim-galore", "0.6.7") | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.pipeline_dir, "trimgalore", "@author", "process_single", True, True, conda_name="trim-galore" | ||
) | ||
module_create.create() | ||
# FIXME This should use the mock? | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.pipeline_dir, "trimgalore", "@author", "process_single", True, True, conda_name="trim-galore" | ||
) | ||
module_create.create() | ||
assert os.path.exists(os.path.join(self.pipeline_dir, "modules", "local", "trimgalore.nf")) | ||
|
||
|
||
def test_modules_create_fail_exists(self): | ||
"""Fail at creating the same module twice""" | ||
with responses.RequestsMock() as rsps: | ||
mock_api_calls(rsps, "trim-galore", "0.6.7") | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.pipeline_dir, "trimgalore", "@author", "process_single", False, False, conda_name="trim-galore" | ||
) | ||
# FIXME This should use the mock? | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.pipeline_dir, "trimgalore", "@author", "process_single", False, False, conda_name="trim-galore" | ||
) | ||
module_create.create() | ||
with pytest.raises(UserWarning) as excinfo: | ||
module_create.create() | ||
with pytest.raises(UserWarning) as excinfo: | ||
module_create.create() | ||
assert "Module file exists already" in str(excinfo.value) | ||
|
||
|
||
def test_modules_create_nfcore_modules(self): | ||
"""Create a module in nf-core/modules clone""" | ||
with responses.RequestsMock() as rsps: | ||
mock_api_calls(rsps, "fastqc", "0.11.9") | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.nfcore_modules, "fastqc", "@author", "process_low", False, False | ||
) | ||
module_create.create() | ||
# FIXME This should use the mock? | ||
module_create = nf_core.modules.ModuleCreate(self.nfcore_modules, "fastqc", "@author", "process_low", False, False) | ||
module_create.create() | ||
assert os.path.exists(os.path.join(self.nfcore_modules, "modules", "nf-core", "fastqc", "main.nf")) | ||
assert os.path.exists(os.path.join(self.nfcore_modules, "tests", "modules", "nf-core", "fastqc", "main.nf")) | ||
|
||
|
||
def test_modules_create_nfcore_modules_subtool(self): | ||
"""Create a tool/subtool module in a nf-core/modules clone""" | ||
with responses.RequestsMock() as rsps: | ||
mock_api_calls(rsps, "star", "2.8.10a") | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.nfcore_modules, "star/index", "@author", "process_medium", False, False | ||
) | ||
module_create.create() | ||
# FIXME This should use the mock? | ||
module_create = nf_core.modules.ModuleCreate( | ||
self.nfcore_modules, "star/index", "@author", "process_medium", False, False | ||
) | ||
module_create.create() | ||
assert os.path.exists(os.path.join(self.nfcore_modules, "modules", "nf-core", "star", "index", "main.nf")) | ||
assert os.path.exists(os.path.join(self.nfcore_modules, "tests", "modules", "nf-core", "star", "index", "main.nf")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters