Skip to content

Commit f01fc20

Browse files
committed
test_pack.py: Add tests to check cwlVersion in pack dict
1 parent d4e142d commit f01fc20

File tree

4 files changed

+59
-35
lines changed

4 files changed

+59
-35
lines changed

tests/test_pack.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,28 @@ def test_pack(self):
3434

3535
self.assertEqual(expect_packed, packed)
3636

37-
def test_pack_single_step(self):
37+
def test_pack_missing_cwlVersion(self):
3838
"""Test to ensure the generated pack output is not missing
39-
the `cwlVersion` in case of single step workflow"""
39+
the `cwlVersion` in case of single tool workflow and single step workflow"""
4040
# Since diff is longer than 3174 characters
4141
self.maxDiff = None
4242

43+
# Testing single tool workflow
44+
document_loader, workflowobj, uri = fetch_document(
45+
get_data("tests/wf/hello_single_tool.cwl"))
46+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
47+
document_loader, workflowobj, uri)
48+
# generate pack output dict
49+
packed = cwltool.pack.pack(document_loader, processobj, uri, metadata)
50+
51+
self.assertEqual('v1.0', packed["$graph"][0]["cwlVersion"])
52+
53+
# Testing single step workflow
4354
document_loader, workflowobj, uri = fetch_document(
4455
get_data("tests/wf/hello-workflow.cwl"))
4556
document_loader, avsc_names, processobj, metadata, uri = validate_document(
4657
document_loader, workflowobj, uri)
4758
# generate pack output dict
4859
packed = cwltool.pack.pack(document_loader, processobj, uri, metadata)
49-
# open expect packed output
50-
with open(get_data("tests/wf/expect_packed_hello_workflow.cwl")) as f:
51-
expect_packed = json.load(f)
52-
print(json.dumps(expect_packed))
53-
adjustFileObjs(packed, partial(makeRelative,
54-
os.path.abspath(get_data("tests/wf"))))
55-
adjustDirObjs(packed, partial(makeRelative,
56-
os.path.abspath(get_data("tests/wf"))))
5760

58-
print(json.dumps(packed["$graph"][0]))
59-
self.assertEqual(expect_packed, packed["$graph"][0])
61+
self.assertEqual('v1.0', packed["$graph"][0]["cwlVersion"])

tests/wf/expect_packed_hello_workflow.cwl

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/wf/hello-workflow.cwl

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1+
#!/usr/bin/env cwl-runner
2+
13
cwlVersion: v1.0
2-
class: CommandLineTool
3-
baseCommand: echo
4+
class: Workflow
5+
6+
label: "Hello World"
7+
doc: "Outputs a message using echo"
8+
49
inputs:
5-
message:
6-
type: string
7-
inputBinding:
8-
position: 1
9-
outputs: []
10+
usermessage: string
11+
12+
outputs:
13+
response:
14+
outputSource: step0/response
15+
type: File
16+
17+
steps:
18+
step0:
19+
run:
20+
class: CommandLineTool
21+
inputs:
22+
message:
23+
type: string
24+
doc: "The message to print"
25+
default: "Hello World"
26+
inputBinding:
27+
position: 1
28+
baseCommand: echo
29+
arguments:
30+
- "-n"
31+
- "-e"
32+
stdout: response.txt
33+
outputs:
34+
response:
35+
type: stdout
36+
in:
37+
message: usermessage
38+
out: [response]

tests/wf/hello_single_tool.cwl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand: echo
4+
inputs:
5+
message:
6+
type: string
7+
inputBinding:
8+
position: 1
9+
outputs: []

0 commit comments

Comments
 (0)