From 6a743aa17dd8b5a3574f641ab11fa1422f225f0b Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 16 Mar 2020 15:14:42 +0000
Subject: [PATCH] TEST: Test case for fot submit behaviour

---
 tests/test_wrapperutils.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/test_wrapperutils.py b/tests/test_wrapperutils.py
index 9e1d5d6a8..104e2cb36 100644
--- a/tests/test_wrapperutils.py
+++ b/tests/test_wrapperutils.py
@@ -584,6 +584,37 @@ def test_fileOrThing_chained_outprefix():
         assert np.all(res['out_array'] == exparr)
 
 
+def test_fileOrThing_submit():
+
+    @wutils.fileOrImage('input', 'output')
+    def func(input, output, submit=False):
+
+        if submit:
+            return 'submitted!'
+
+        img = nib.load(input)
+        img = nib.nifti1.Nifti1Image(np.asanyarray(img.dataobj) * 2, np.eye(4))
+
+        nib.save(img, output)
+
+    with tempdir.tempdir() as td:
+        img = nib.nifti1.Nifti1Image(np.array([[1, 2], [3, 4]]), np.eye(4))
+        exp = np.asanyarray(img.dataobj) * 2
+        nib.save(img, 'input.nii.gz')
+
+        result = func(img, wutils.LOAD)
+        assert np.all(np.asanyarray(result['output'].dataobj) == exp)
+
+        assert func('input.nii.gz', 'output.nii.gz', submit=True) == 'submitted!'
+
+        with pytest.raises(ValueError):
+            func(img, wutils.LOAD, submit=True)
+        with pytest.raises(ValueError):
+            func(img, 'output.nii.gz', submit=True)
+        with pytest.raises(ValueError):
+            func('input.nii.gz', wutils.LOAD, submit=True)
+
+
 def test_cmdwrapper():
     @wutils.cmdwrapper
     def func(a, b):
-- 
GitLab