1515
1616class IntegrationTest (unittest .TestCase ):
1717 """A baseclass that's inherited for use with different cwl backends."""
18+
1819 def setUp (self ):
1920 """Start a (local) wes-service server to make requests against."""
2021 raise NotImplementedError
@@ -30,6 +31,7 @@ def tearDown(self):
3031 except OSError as e :
3132 print (e )
3233 if os .path .exists ('workflows' ):
34+ pass
3335 shutil .rmtree ('workflows' )
3436 unittest .TestCase .tearDown (self )
3537
@@ -43,31 +45,53 @@ def test_dockstore_md5sum(self):
4345 def test_local_md5sum (self ):
4446 """Pass a local md5sum cwl to the wes-service server, and check for the correct output."""
4547 cwl_local_path = os .path .abspath ('testdata/md5sum.cwl' )
46- output_filepath , _ = run_cwl_md5sum (cwl_input = 'file://' + cwl_local_path )
48+ workflow_attachment_path = os .path .abspath ('testdata/dockstore-tool-md5sum.cwl' )
49+ output_filepath , _ = run_cwl_md5sum (cwl_input = 'file://' + cwl_local_path ,
50+ workflow_attachment = 'file://' + workflow_attachment_path )
4751
4852 self .assertTrue (check_for_file (output_filepath ), 'Output file was not found: ' + str (output_filepath ))
4953
5054 def test_multipart_upload (self ):
5155 """Pass a local md5sum cwl to the wes-service server, and check for uploaded file in service."""
5256 cwl_local_path = os .path .abspath ('testdata/md5sum.cwl' )
53- _ , run_id = run_cwl_md5sum (cwl_input = 'file://' + cwl_local_path )
57+ workflow_attachment_path = os .path .abspath ('testdata/dockstore-tool-md5sum.cwl' )
58+ out_file_path , run_id = run_cwl_md5sum (cwl_input = 'file://' + cwl_local_path ,
59+ workflow_attachment = 'file://' + workflow_attachment_path )
5460
5561 get_response = get_log_request (run_id )["request" ]
5662
63+ self .assertTrue (check_for_file (out_file_path ), 'Output file was not found: '
64+ + get_response ["workflow_attachment" ])
5765 self .assertTrue (check_for_file (get_response ["workflow_url" ][7 :]), 'Output file was not found: '
5866 + get_response ["workflow_url" ][:7 ])
5967
68+ def test_run_attachments (self ):
69+ """Pass a local md5sum cwl to the wes-service server, check for attachments."""
70+ cwl_local_path = os .path .abspath ('testdata/md5sum.cwl' )
71+ workflow_attachment_path = os .path .abspath ('testdata/dockstore-tool-md5sum.cwl' )
72+ out_file_path , run_id = run_cwl_md5sum (cwl_input = 'file://' + cwl_local_path ,
73+ workflow_attachment = 'file://' + workflow_attachment_path )
74+
75+ get_response = get_log_request (run_id )["request" ]
76+ attachment_tool_path = get_response ["workflow_attachment" ][7 :] + "/dockstore-tool-md5sum.cwl"
77+ self .assertTrue (check_for_file (out_file_path ), 'Output file was not found: '
78+ + get_response ["workflow_attachment" ])
79+ self .assertTrue (check_for_file (attachment_tool_path ), 'Attachment file was not found: '
80+ + get_response ["workflow_attachment" ])
81+
6082
61- def run_cwl_md5sum (cwl_input ):
83+ def run_cwl_md5sum (cwl_input , workflow_attachment = None ):
6284 """Pass a local md5sum cwl to the wes-service server, and return the path of the output file that was created."""
6385 endpoint = 'http://localhost:8080/ga4gh/wes/v1/runs'
6486 params = {'output_file' : {'path' : '/tmp/md5sum.txt' , 'class' : 'File' },
6587 'input_file' : {'path' : os .path .abspath ('testdata/md5sum.input' ), 'class' : 'File' }}
6688
6789 parts = [("workflow_params" , json .dumps (params )), ("workflow_type" , "CWL" ), ("workflow_type_version" , "v1.0" )]
6890 if cwl_input .startswith ("file://" ):
69- parts .append (("workflow_descriptor " , ("md5sum.cwl" , open (cwl_input [7 :], "rb" ))))
91+ parts .append (("workflow_attachment " , ("md5sum.cwl" , open (cwl_input [7 :], "rb" ))))
7092 parts .append (("workflow_url" , os .path .basename (cwl_input [7 :])))
93+ if workflow_attachment :
94+ parts .append (("workflow_attachment" , ("dockstore-tool-md5sum.cwl" , open (workflow_attachment [7 :], "rb" ))))
7195 else :
7296 parts .append (("workflow_url" , cwl_input ))
7397 response = requests .post (endpoint , files = parts ).json ()
0 commit comments