Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrosenbaum committed May 3, 2019
1 parent 49c7988 commit b89e086
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
15 changes: 10 additions & 5 deletions mutacc_auto/cli/import_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ def parse_path(ctx, param, value):
return value

@click.command('import')
@click.option('-C','--config-file',
type=click.Path(exists=True),
callback=parse_path,
help="configuration file used for mutacc")
@click.option('-D','--dry',
is_flag=True,
help="dry run")
is_flag=True,
help="dry run")
@click.option('-V','--verbose',
is_flag=True,
help="verbose")
is_flag=True,
help="verbose")
@click.pass_context
def import_command(ctx,
config_file,
dry,
verbose):

mutacc_config = ctx.obj['mutacc_config']
mutacc_config = ctx.obj.get('mutacc_config') or config_file
#Open and read config for mutacc
with open(Path(mutacc_config)) as yaml_handle:

Expand Down
16 changes: 8 additions & 8 deletions mutacc_auto/recipes/input_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def get_bams(case_id, hk_config=None, hk_binary=None):
bam_paths (dict): dict with paths to bam for each sample
"""

#housekeeper_command = HousekeeperCommand(
# case_id=case_id,
# config_file=hk_config,
# hk_binary=hk_binary
#)
#hk_output = housekeeper_command.check_output()
housekeeper_command = HousekeeperCommand(
case_id=case_id,
config_file=hk_config,
hk_binary=hk_binary
)
hk_output = housekeeper_command.check_output()
###
hk_out = subprocess.check_output(['cat', '/Users/adam.rosenbaum/develop/mutacc_auto/tests/fixtures/HK_output_test.txt'])
hk_output = hk_out.decode('utf-8')
#hk_out = subprocess.check_output(['cat', '/Users/adam.rosenbaum/develop/mutacc_auto/tests/fixtures/HK_output_test.txt'])
#hk_output = hk_out.decode('utf-8')
###
bam_paths = get_bams_from_housekeeper(hk_output)

Expand Down
25 changes: 11 additions & 14 deletions tests/cli/test_extract_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,24 @@ def test_extract_command(

with open(tmp_dir.joinpath('tmp_conf.yaml'), 'w') as conf_handle:

conf_dict = {'case_dir': str(tmp_dir)}
conf_dict = {'case_dir': str(tmp_dir), 'root_dir': str(tmp_dir)}
yaml.dump(conf_dict, conf_handle)
conf_path = conf_handle.name

with open(tmp_dir.joinpath('tmp_test.mutacc'), 'w') as handle:
handle.write('\n')

runner = CliRunner()
result = runner.invoke(cli, [
'--config-file', configuration_file,
'extract',
'--case-id', 'test_id',
'--environment', 'env',
'--mutacc-config', conf_path,
'--log-directory', str(tmp_dir),
'--email', 'email@email.com',
'--dry',
'--verbose'
]
)

result = runner.invoke(cli, ['--config-file', configuration_file,
'extract',
'--case-id', 'test_id',
'--environment', 'env',
'--mutacc-config', conf_path,
'--log-directory', str(tmp_dir),
'--email', 'email@email.com',
'--dry',
'--verbose'])
#mock_mkdir.assert_called_with('dsa')
assert result.exit_code == 0

result = runner.invoke(cli, [
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/config_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ scout_config: /path/to/scout_config
scout_binary: /path/to/scout
housekeeper_config: /path/to/housekeeper_config
housekeeper_binary: /path/to/housekeeper
mutacc_config: /path/to/mutacc_config
mutacc_config: /Users/adam.rosenbaum/develop/mutacc_auto/tests/fixtures/mutacc_config.yaml
mutacc_binary: /path/to/mutacc

slurm:
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/mutacc_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
root_dir: path/to/root/
13 changes: 6 additions & 7 deletions tests/utils/test_tmp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@

from mutacc_auto.utils.tmp_dir import TemporaryDirectory

def test_TemporaryDirectory():
def test_TemporaryDirectory(tmpdir):

with TemporaryDirectory() as tmp_dir:
with TemporaryDirectory(directory=tmpdir) as tmp_dir:

assert Path(tmp_dir).exists()
assert Path(tmp_dir).is_dir()

assert not Path(tmp_dir).exists()
assert Path(tmp_dir).exists()
rmtree(tmp_dir)

with TemporaryDirectory(delete_dir=False) as tmp_dir:
with TemporaryDirectory(directory=tmpdir, delete_dir=True) as tmp_dir:

assert Path(tmp_dir).exists()
assert Path(tmp_dir).is_dir()

assert Path(tmp_dir).exists()
rmtree(tmp_dir)

assert not Path(tmp_dir).exists()

0 comments on commit b89e086

Please sign in to comment.