|
15 | 15 |
|
16 | 16 | class IntegrationTest(unittest.TestCase): |
17 | 17 | """A baseclass that's inherited for use with different cwl backends.""" |
| 18 | + |
18 | 19 | def setUp(self): |
19 | 20 | """Start a (local) wes-service server to make requests against.""" |
20 | 21 | raise NotImplementedError |
@@ -43,31 +44,53 @@ def test_dockstore_md5sum(self): |
43 | 44 | def test_local_md5sum(self): |
44 | 45 | """Pass a local md5sum cwl to the wes-service server, and check for the correct output.""" |
45 | 46 | cwl_local_path = os.path.abspath('testdata/md5sum.cwl') |
46 | | - output_filepath, _ = run_cwl_md5sum(cwl_input='file://' + cwl_local_path) |
| 47 | + workflow_attachment_path = os.path.abspath('testdata/dockstore-tool-md5sum.cwl') |
| 48 | + output_filepath, _ = run_cwl_md5sum(cwl_input='file://' + cwl_local_path, |
| 49 | + workflow_attachment='file://' + workflow_attachment_path) |
47 | 50 |
|
48 | 51 | self.assertTrue(check_for_file(output_filepath), 'Output file was not found: ' + str(output_filepath)) |
49 | 52 |
|
50 | 53 | def test_multipart_upload(self): |
51 | 54 | """Pass a local md5sum cwl to the wes-service server, and check for uploaded file in service.""" |
52 | 55 | cwl_local_path = os.path.abspath('testdata/md5sum.cwl') |
53 | | - _, run_id = run_cwl_md5sum(cwl_input='file://' + cwl_local_path) |
| 56 | + workflow_attachment_path = os.path.abspath('testdata/dockstore-tool-md5sum.cwl') |
| 57 | + out_file_path, run_id = run_cwl_md5sum(cwl_input='file://' + cwl_local_path, |
| 58 | + workflow_attachment='file://' + workflow_attachment_path) |
54 | 59 |
|
55 | 60 | get_response = get_log_request(run_id)["request"] |
56 | 61 |
|
| 62 | + self.assertTrue(check_for_file(out_file_path), 'Output file was not found: ' |
| 63 | + + get_response["workflow_attachment"]) |
57 | 64 | self.assertTrue(check_for_file(get_response["workflow_url"][7:]), 'Output file was not found: ' |
58 | 65 | + get_response["workflow_url"][:7]) |
59 | 66 |
|
| 67 | + def test_run_attachments(self): |
| 68 | + """Pass a local md5sum cwl to the wes-service server, check for attachments.""" |
| 69 | + cwl_local_path = os.path.abspath('testdata/md5sum.cwl') |
| 70 | + workflow_attachment_path = os.path.abspath('testdata/dockstore-tool-md5sum.cwl') |
| 71 | + out_file_path, run_id = run_cwl_md5sum(cwl_input='file://' + cwl_local_path, |
| 72 | + workflow_attachment='file://' + workflow_attachment_path) |
| 73 | + |
| 74 | + get_response = get_log_request(run_id)["request"] |
| 75 | + attachment_tool_path = get_response["workflow_attachment"][7:] + "/dockstore-tool-md5sum.cwl" |
| 76 | + self.assertTrue(check_for_file(out_file_path), 'Output file was not found: ' |
| 77 | + + get_response["workflow_attachment"]) |
| 78 | + self.assertTrue(check_for_file(attachment_tool_path), 'Attachment file was not found: ' |
| 79 | + + get_response["workflow_attachment"]) |
| 80 | + |
60 | 81 |
|
61 | | -def run_cwl_md5sum(cwl_input): |
| 82 | +def run_cwl_md5sum(cwl_input, workflow_attachment=None): |
62 | 83 | """Pass a local md5sum cwl to the wes-service server, and return the path of the output file that was created.""" |
63 | 84 | endpoint = 'http://localhost:8080/ga4gh/wes/v1/runs' |
64 | 85 | params = {'output_file': {'path': '/tmp/md5sum.txt', 'class': 'File'}, |
65 | 86 | 'input_file': {'path': os.path.abspath('testdata/md5sum.input'), 'class': 'File'}} |
66 | 87 |
|
67 | 88 | parts = [("workflow_params", json.dumps(params)), ("workflow_type", "CWL"), ("workflow_type_version", "v1.0")] |
68 | 89 | if cwl_input.startswith("file://"): |
69 | | - parts.append(("workflow_descriptor", ("md5sum.cwl", open(cwl_input[7:], "rb")))) |
| 90 | + parts.append(("workflow_attachment", ("md5sum.cwl", open(cwl_input[7:], "rb")))) |
70 | 91 | parts.append(("workflow_url", os.path.basename(cwl_input[7:]))) |
| 92 | + if workflow_attachment: |
| 93 | + parts.append(("workflow_attachment", ("dockstore-tool-md5sum.cwl", open(workflow_attachment[7:], "rb")))) |
71 | 94 | else: |
72 | 95 | parts.append(("workflow_url", cwl_input)) |
73 | 96 | response = requests.post(endpoint, files=parts).json() |
|
0 commit comments