-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(tests) Improve panel pytest (#2682)(patch)
### Added - New test for the `panel` function
- Loading branch information
1 parent
2e193e9
commit fe99adb
Showing
7 changed files
with
104 additions
and
29 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
""" Test the CLI for mip-dna panel""" | ||
from pathlib import Path | ||
|
||
import mock | ||
from click.testing import CliRunner | ||
|
||
from cg.cli.workflow.mip_dna.base import panel | ||
from cg.io.txt import read_txt | ||
from cg.meta.workflow.mip import MipAnalysisAPI | ||
from cg.models.cg_config import CGConfig | ||
from tests.conftest import create_process_response | ||
|
||
|
||
def test_panel_file_is_written( | ||
case_id: str, cli_runner: CliRunner, mip_dna_context: CGConfig, scout_panel_output: str | ||
): | ||
analysis_api: MipAnalysisAPI = mip_dna_context.meta_apis["analysis_api"] | ||
|
||
# GIVEN a case | ||
|
||
def test_cg_workflow_mip_dna_panel(cli_runner, case_id, mip_dna_context): | ||
"""Test print the MIP dna panel command to console""" | ||
# GIVEN that the scout command writes the panel to stdout | ||
with mock.patch( | ||
"cg.utils.commands.subprocess.run", | ||
return_value=create_process_response(std_out=scout_panel_output), | ||
): | ||
# WHEN creating a panel file | ||
cli_runner.invoke(panel, [case_id], obj=mip_dna_context) | ||
|
||
# GIVEN a cli function | ||
panel_file = Path(analysis_api.root, case_id, "gene_panels.bed") | ||
|
||
# WHEN we run a case in dry run mode | ||
result = cli_runner.invoke(panel, [case_id], obj=mip_dna_context) | ||
# THEN the file should exist | ||
assert panel_file.exists() | ||
|
||
# THEN the command should be printed | ||
assert result.exit_code == 0 | ||
# THEN the file should contain the output from scout | ||
file_content: str = read_txt(file_path=panel_file, read_to_string=True) | ||
assert file_content == scout_panel_output |
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
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