From 44b096c9a555b3c97ef19e389a4de671499d0108 Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Fri, 26 Apr 2024 09:38:36 -0400 Subject: [PATCH] Add test to showcase error --- scripts/scil_volume_resample.py | 1 + scripts/tests/test_volume_resample.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/scil_volume_resample.py b/scripts/scil_volume_resample.py index e65e5b853..1c74e005d 100755 --- a/scripts/scil_volume_resample.py +++ b/scripts/scil_volume_resample.py @@ -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") diff --git a/scripts/tests/test_volume_resample.py b/scripts/tests/test_volume_resample.py index 947bbd59c..884f2cb7d 100644 --- a/scripts/tests/test_volume_resample.py +++ b/scripts/tests/test_volume_resample.py @@ -10,6 +10,7 @@ # 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): @@ -17,10 +18,16 @@ def test_help_option(script_runner): 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