Skip to content

Commit

Permalink
Merge branch 'nicolocin-skip_symlink_hash' of github.com:djarecka/pyd…
Browse files Browse the repository at this point in the history
…ra into skip_symlink_hash
  • Loading branch information
nicolocin committed Oct 4, 2020
2 parents ae2a135 + 4b93c0c commit 8863dc7
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions pydra/engine/tests/test_shelltask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,56 @@ def test_shell_cmd_inputspec_10(plugin, results_function, tmpdir):
assert res.output.stdout == "hello from boston"


def test_shell_cmd_inputspec_10_err(tmpdir):
""" checking if the proper error is raised when broken symlink is provided
as a input field with File as a type
"""

file_1 = tmpdir.join("file_1.txt")
with open(file_1, "w") as f:
f.write("hello")
file_2 = tmpdir.join("file_2.txt")

# creating symlink and removing the original file
os.symlink(file_1, file_2)
os.remove(file_1)

cmd_exec = "cat"

my_input_spec = SpecInfo(
name="Input",
fields=[
(
"files",
attr.ib(
type=File,
metadata={
"position": 1,
"argstr": "",
"help_string": "a file",
"mandatory": True,
},
),
)
],
bases=(ShellSpec,),
)

shelly = ShellCommandTask(
name="shelly", executable=cmd_exec, files=file_2, input_spec=my_input_spec
)

# checking if the broken symlink error is raised when checksum is calculated
with pytest.raises(FileNotFoundError) as e:
checksum = shelly.checksum
assert "Broken symlink" in str(e.value)

# checking if the broken symlink error is raised when the task is run
with pytest.raises(FileNotFoundError) as e:
res = shelly()
assert "Broken symlink" in str(e.value)


@pytest.mark.parametrize("results_function", [result_no_submitter, result_submitter])
def test_shell_cmd_inputspec_copyfile_1(plugin, results_function, tmpdir):
""" shelltask changes a file in place,
Expand Down

0 comments on commit 8863dc7

Please sign in to comment.