Skip to content

Commit 23ad734

Browse files
committed
test_pack.py: add test for single item workflow
1 parent 5c83b3e commit 23ad734

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

tests/test_pack.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,27 @@ def test_pack(self):
3333
del expect_packed["$schemas"]
3434

3535
self.assertEqual(expect_packed, packed)
36+
37+
def test_pack_single_item(self):
38+
"""Test to ensure the generated pack output is not missing
39+
the `cwlVersion` in case of single item workflow"""
40+
# Since diff is longer than 3174 characters
41+
self.maxDiff = None
42+
43+
document_loader, workflowobj, uri = fetch_document(
44+
get_data("tests/wf/hello-workflow.cwl"))
45+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
46+
document_loader, workflowobj, uri)
47+
# generate pack output dict
48+
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"))))
57+
58+
print(json.dumps(packed["$graph"][0]))
59+
self.assertEqual(expect_packed, packed["$graph"][0])
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"class": "CommandLineTool",
3+
"baseCommand": "echo",
4+
"inputs": [
5+
{
6+
"type": "string",
7+
"inputBinding": {
8+
"position": 1
9+
},
10+
"id": "#main/message"
11+
}
12+
],
13+
"outputs": [],
14+
"id": "#main",
15+
"cwlVersion": "v1.0"
16+
}

tests/wf/hello-workflow.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)