-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified cli to export panels and created a test for it
- Loading branch information
1 parent
df06b65
commit 06cb135
Showing
4 changed files
with
80 additions
and
18 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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from scout.commands import app_cli | ||
from scout.server.extensions import store | ||
|
||
def test_export_panel(mock_app): | ||
"""Test the CLI command that exports a gene panel""" | ||
|
||
runner = mock_app.test_cli_runner() | ||
assert runner | ||
|
||
panel_obj = store.panel_collection.find_one() | ||
assert panel_obj | ||
|
||
# Test the export panel cli without passing any data | ||
result = runner.invoke(app_cli, ['export', 'panel']) | ||
|
||
# The CLI command should return an error message then return abort code | ||
assert result.exit_code == 1 | ||
assert 'Please provide at least one gene panel' in result.output | ||
|
||
# Try to pass a non-valid panel name | ||
result = runner.invoke(app_cli, ['export', 'panel', 'unknown_panel']) | ||
|
||
# The CLI command should not return abort code but error message | ||
assert result.exit_code == 0 | ||
assert 'WARNING Panel unknown_panel could not be found' in result.output | ||
|
||
# Try to pass a valid panel name, without a valid version | ||
result = runner.invoke(app_cli, ['export', 'panel', | ||
panel_obj['panel_name'], | ||
'--version', 5.0 | ||
]) | ||
|
||
# The CLI command should not return abort code but error message | ||
assert result.exit_code == 0 | ||
assert 'WARNING Panel {} could not be found'.format(panel_obj['panel_name']) in result.output | ||
|
||
# Pass a valid panel name, valid version | ||
result = runner.invoke(app_cli, ['export', 'panel', | ||
panel_obj['panel_name'], | ||
'--version', 1.0 | ||
]) | ||
|
||
# The CLI command shoud return gene panel | ||
assert result.exit_code == 0 | ||
assert '2397\tCRYBB1\t\t\t\t\n9394\tPICK1\t\t\t\t\n' in result.output | ||
|
||
# Pass a valid panel name, valid version, bed file format option | ||
result = runner.invoke(app_cli, ['export', 'panel', | ||
panel_obj['panel_name'], | ||
'--version', 1.0, | ||
'--bed' | ||
]) | ||
|
||
# The CLI command shoud return gene panel formatted in the expexted way | ||
assert result.exit_code == 0 | ||
assert '22\t26995242\t27014052\t2397\tCRYBB1\n22\t38452318\t38471708\t9394\tPICK1\n' in result.output |