Skip to content

Commit 118b7cd

Browse files
Ryan CaliRyan Cali
authored andcommitted
Fixed tests
1 parent bf593de commit 118b7cd

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

pydra/engine/tests/test_task.py

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]
10071007
funky.cache_dir = tmpdir
10081008
funky()
10091009
message_path = tmpdir / funky.checksum / "messages"
1010-
print(message_path)
1010+
10111011

10121012
for file in glob(str(message_path) + "/*.jsonld"):
10131013
with open(file, "r") as f:
@@ -1019,12 +1019,6 @@ def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]
10191019
if "@type" in data:
10201020
if data["@type"] == "input":
10211021
assert None == data["Label"]
1022-
# placeholder for atlocation until
1023-
# new test is added
1024-
assert [] == data["AtLocation"]
1025-
1026-
# assert data["Type"] == "input"
1027-
10281022
if "AssociatedWith" in data:
10291023
assert None == data["AssociatedWith"]
10301024

@@ -1070,19 +1064,21 @@ def test_audit_shellcommandtask(tmpdir):
10701064

10711065

10721066
def test_audit_shellcommandtask_file(tmpdir):
1067+
# sourcery skip: use-fstring-for-concatenation
1068+
import glob
10731069
import shutil
1074-
10751070
# create test.txt file with "This is a test" in it in the tmpdir
1076-
with open(tmpdir / "test.txt", "w") as f:
1077-
f.write("This is a test.")
1078-
# make a copy of the test.txt file in the tmpdir and name it test2.txt
1079-
shutil.copy(tmpdir / "test.txt", tmpdir / "test2.txt")
1071+
# create txt file in cwd
1072+
with open("test.txt", "w") as f:
1073+
f.write("This is a test")
1074+
1075+
# copy the test.txt file to the tmpdir
1076+
shutil.copy("test.txt", tmpdir)
1077+
10801078

10811079
cmd = "cat"
10821080
file_in = tmpdir / "test.txt"
1083-
file_in_2 = tmpdir / "test2.txt"
10841081
test_file_hash = hash_file(file_in)
1085-
test_file_hash_2 = hash_file(file_in_2)
10861082
my_input_spec = SpecInfo(
10871083
name="Input",
10881084
fields=[
@@ -1098,43 +1094,30 @@ def test_audit_shellcommandtask_file(tmpdir):
10981094
},
10991095
),
11001096
),
1101-
(
1102-
"in_file_2",
1103-
attr.ib(
1104-
type=File,
1105-
metadata={
1106-
"position": 2,
1107-
"argstr": "",
1108-
"help_string": "text",
1109-
"mandatory": True,
1110-
},
1111-
),
1112-
),
11131097
],
11141098
bases=(ShellSpec,),
11151099
)
11161100
shelly = ShellCommandTask(
11171101
name="shelly",
11181102
in_file=file_in,
1119-
in_file_2=file_in_2,
11201103
input_spec=my_input_spec,
11211104
executable=cmd,
11221105
audit_flags=AuditFlag.PROV,
1123-
messengers=PrintMessenger(),
1106+
messengers=FileMessenger(),
11241107
)
11251108
shelly.cache_dir = tmpdir
11261109
shelly()
11271110
message_path = tmpdir / shelly.checksum / "messages"
11281111
for file in glob.glob(str(message_path) + "/*.jsonld"):
1129-
with open(file, "r") as f:
1130-
data = json.load(f)
1131-
print(file_in)
1132-
if "AtLocation" in data:
1133-
assert data["AtLocation"] == [file_in, file_in_2]
1134-
if "digest" in data:
1135-
assert data["digest"] == [test_file_hash, test_file_hash_2]
1136-
1137-
1112+
with open(file, "r") as x:
1113+
data = json.load(x)
1114+
if "@type" in data:
1115+
if data["@type"] == "input":
1116+
if "AtLocation" in data:
1117+
assert data["AtLocation"] == str(file_in)
1118+
if "digest" in data:
1119+
assert data["digest"] == test_file_hash
1120+
11381121
def test_audit_shellcommandtask_version(tmpdir):
11391122
import subprocess as sp
11401123

0 commit comments

Comments
 (0)