Skip to content

Commit 696c8ae

Browse files
committed
strengthen test
1 parent e8a10a8 commit 696c8ae

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

tests/test_pack.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import os
77
from functools import partial
8+
import tempfile
89

910
import pytest
1011
from six import StringIO
@@ -47,7 +48,7 @@ def test_pack_missing_cwlVersion(self):
4748
# Testing single tool workflow
4849
document_loader, workflowobj, uri = fetch_document(
4950
get_data("tests/wf/hello_single_tool.cwl"))
50-
document_loader, avsc_names, processobj, metadata, uri = validate_document(
51+
document_loader, _, processobj, metadata, uri = validate_document(
5152
document_loader, workflowobj, uri)
5253
# generate pack output dict
5354
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
@@ -57,7 +58,7 @@ def test_pack_missing_cwlVersion(self):
5758
# Testing single step workflow
5859
document_loader, workflowobj, uri = fetch_document(
5960
get_data("tests/wf/hello-workflow.cwl"))
60-
document_loader, avsc_names, processobj, metadata, uri = validate_document(
61+
document_loader, _, processobj, metadata, uri = validate_document(
6162
document_loader, workflowobj, uri)
6263
# generate pack output dict
6364
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
@@ -103,7 +104,7 @@ def test_packed_workflow_execution(self):
103104
document_loader, avsc_names, processobj, metadata, uri = validate_document(
104105
document_loader, workflowobj, uri)
105106
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
106-
temp_packed_path = "/tmp/packedwf"
107+
temp_packed_path = tempfile.mkstemp()[1]
107108
with open(temp_packed_path, 'w') as f:
108109
json.dump(packed, f)
109110
normal_output = StringIO()
@@ -115,16 +116,30 @@ def test_packed_workflow_execution(self):
115116
get_data(test_wf_job)],
116117
stdout=normal_output), 0)
117118
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
119+
os.remove(temp_packed_path)
118120

119121
@pytest.mark.skipif(onWindows(),
120122
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
121123
"which is not supported on AppVeyor")
122124
def test_preserving_namespaces(self):
123125
test_wf = "tests/wf/formattest.cwl"
126+
test_wf_job = "tests/wf/formattest-job.json"
124127
document_loader, workflowobj, uri = fetch_document(
125128
get_data(test_wf))
126129
document_loader, avsc_names, processobj, metadata, uri = validate_document(
127130
document_loader, workflowobj, uri)
128131
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
129132
assert "$namespaces" in packed
130-
133+
temp_packed_path = tempfile.mkstemp()[1]
134+
with open(temp_packed_path, 'w') as f:
135+
json.dump(packed, f)
136+
normal_output = StringIO()
137+
packed_output = StringIO()
138+
self.assertEquals(main(['--debug', get_data(temp_packed_path),
139+
get_data(test_wf_job)],
140+
stdout=packed_output), 0)
141+
self.assertEquals(main([get_data(test_wf),
142+
get_data(test_wf_job)],
143+
stdout=normal_output), 0)
144+
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
145+
os.remove(temp_packed_path)

tests/wf/formattest-job.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"input": {
3+
"class": "File",
4+
"location": "whale.txt",
5+
"format": "edam:format_2330"
6+
}
7+
}

0 commit comments

Comments
 (0)