Skip to content

Commit

Permalink
Add test to showcase error
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed Apr 26, 2024
1 parent 9b79ea4 commit 44b096c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/scil_volume_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def main():
assert_inputs_exist(parser, args.in_image, args.ref)
assert_outputs_exist(parser, args, args.out_image)
assert_headers_compatible(parser, args.in_image, args.ref)
assert_headers_compatible(parser, args.in_image, args.ref)

if args.enforce_dimensions and not args.ref:
parser.error("Cannot enforce dimensions without a reference image")
Expand Down
13 changes: 10 additions & 3 deletions scripts/tests/test_volume_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@
# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['others.zip'])
tmp_dir = tempfile.TemporaryDirectory()
in_img = os.path.join(SCILPY_HOME, 'others', 'fa.nii.gz')


def test_help_option(script_runner):
ret = script_runner.run('scil_volume_resample.py', '--help')
assert ret.success


def test_execution_others(script_runner, monkeypatch):
def test_execution_given_size(script_runner, monkeypatch):
monkeypatch.chdir(os.path.expanduser(tmp_dir.name))
in_img = os.path.join(SCILPY_HOME, 'others',
'fa.nii.gz')
ret = script_runner.run('scil_volume_resample.py', in_img,
'fa_resample.nii.gz', '--voxel_size', '2')
assert ret.success


def test_execution_ref(script_runner, monkeypatch):
monkeypatch.chdir(os.path.expanduser(tmp_dir.name))
ref = os.path.join(SCILPY_HOME, 'others', 'fa_resample.nii.gz')
ret = script_runner.run('scil_volume_resample.py', in_img,
'fa_resample2.nii.gz', '--ref', ref)
assert ret.success

0 comments on commit 44b096c

Please sign in to comment.