@@ -1007,7 +1007,7 @@ def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]
1007
1007
funky .cache_dir = tmpdir
1008
1008
funky ()
1009
1009
message_path = tmpdir / funky .checksum / "messages"
1010
- print ( message_path )
1010
+
1011
1011
1012
1012
for file in glob (str (message_path ) + "/*.jsonld" ):
1013
1013
with open (file , "r" ) as f :
@@ -1019,12 +1019,6 @@ def testfunc(a: int, b: float = 0.1) -> ty.NamedTuple("Output", [("out", float)]
1019
1019
if "@type" in data :
1020
1020
if data ["@type" ] == "input" :
1021
1021
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
-
1028
1022
if "AssociatedWith" in data :
1029
1023
assert None == data ["AssociatedWith" ]
1030
1024
@@ -1070,19 +1064,21 @@ def test_audit_shellcommandtask(tmpdir):
1070
1064
1071
1065
1072
1066
def test_audit_shellcommandtask_file (tmpdir ):
1067
+ # sourcery skip: use-fstring-for-concatenation
1068
+ import glob
1073
1069
import shutil
1074
-
1075
1070
# 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
+
1080
1078
1081
1079
cmd = "cat"
1082
1080
file_in = tmpdir / "test.txt"
1083
- file_in_2 = tmpdir / "test2.txt"
1084
1081
test_file_hash = hash_file (file_in )
1085
- test_file_hash_2 = hash_file (file_in_2 )
1086
1082
my_input_spec = SpecInfo (
1087
1083
name = "Input" ,
1088
1084
fields = [
@@ -1098,43 +1094,30 @@ def test_audit_shellcommandtask_file(tmpdir):
1098
1094
},
1099
1095
),
1100
1096
),
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
- ),
1113
1097
],
1114
1098
bases = (ShellSpec ,),
1115
1099
)
1116
1100
shelly = ShellCommandTask (
1117
1101
name = "shelly" ,
1118
1102
in_file = file_in ,
1119
- in_file_2 = file_in_2 ,
1120
1103
input_spec = my_input_spec ,
1121
1104
executable = cmd ,
1122
1105
audit_flags = AuditFlag .PROV ,
1123
- messengers = PrintMessenger (),
1106
+ messengers = FileMessenger (),
1124
1107
)
1125
1108
shelly .cache_dir = tmpdir
1126
1109
shelly ()
1127
1110
message_path = tmpdir / shelly .checksum / "messages"
1128
1111
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
+
1138
1121
def test_audit_shellcommandtask_version (tmpdir ):
1139
1122
import subprocess as sp
1140
1123
0 commit comments