44import subprocess
55import sys
66
7- pkg_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' )) # noqa
7+ pkg_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." )) # noqa
88sys .path .insert (0 , pkg_root ) # noqa
99
1010from wes_client .util import expand_globs , wf_info
1515class IntegrationTest (unittest .TestCase ):
1616 def setUp (self ):
1717 dirname , filename = os .path .split (os .path .abspath (__file__ ))
18- self .testdata_dir = dirname + 'data'
19- self .local = {'cwl' : 'file://' + os .path .join (os .getcwd () + '/testdata/md5sum.cwl' ),
20- 'wdl' : 'file://' + os .path .join (os .getcwd () + '/testdata/md5sum.wdl' ),
21- 'py' : 'file://' + os .path .join (os .getcwd () + '/test/test_integration.py' ),
22- 'unsupported' : 'fake.txt' }
18+ self .testdata_dir = dirname + "data"
19+ self .local = {
20+ "cwl" : "file://" + os .path .join (os .getcwd () + "/testdata/md5sum.cwl" ),
21+ "wdl" : "file://" + os .path .join (os .getcwd () + "/testdata/md5sum.wdl" ),
22+ "py" : "file://" + os .path .join (os .getcwd () + "/test/test_integration.py" ),
23+ "unsupported" : "fake.txt" ,
24+ }
2325
2426 self .remote = {
25- 'cwl' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl' ,
26- 'wdl' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl' ,
27- 'py' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/test/test_integration.py' ,
28- 'unsupported' : 'gs://topmed_workflow_testing/topmed_aligner/small_test_files_sbg/example_human_known_snp.py' ,
29- 'unreachable' : 'https://fake.py' }
30-
31- self .expected = {'cwl' : ('v1.0' , 'CWL' ),
32- 'wdl' : ('draft-2' , 'WDL' ),
33- 'py' : ('2.7' , 'PY' ),
34- 'pyWithPrefix' : ('2.7' , 'PY' )}
27+ "cwl" : "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl" ,
28+ "wdl" : "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl" ,
29+ "py" : "https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/test/test_integration.py" ,
30+ "unsupported" : "gs://topmed_workflow_testing/topmed_aligner/small_test_files_sbg/example_human_known_snp.py" ,
31+ "unreachable" : "https://fake.py" ,
32+ }
33+
34+ self .expected = {
35+ "cwl" : ("v1.0" , "CWL" ),
36+ "wdl" : ("draft-2" , "WDL" ),
37+ "py" : ("2.7" , "PY" ),
38+ "pyWithPrefix" : ("2.7" , "PY" ),
39+ }
3540
3641 def tearDown (self ):
3742 unittest .TestCase .tearDown (self )
3843
3944 def test_expand_globs (self ):
4045 """Asserts that wes_client.expand_globs() sees the same files in the cwd as 'ls'."""
41- files = subprocess .check_output (['ls' , '-1' , '.' ])
46+ files = subprocess .check_output (["ls" , "-1" , "." ])
4247
4348 # python 2/3 bytestring/utf-8 compatibility
4449 if isinstance (files , str ):
45- files = files .split (' \n ' )
50+ files = files .split (" \n " )
4651 else :
47- files = files .decode (' utf-8' ).split (' \n ' )
52+ files = files .decode (" utf-8" ).split (" \n " )
4853
49- if '' in files :
50- files .remove ('' )
51- files = [' file://' + os .path .abspath (f ) for f in files ]
52- glob_files = expand_globs ('*' )
53- assert set (files ) == glob_files , ' \n ' + str (set (files )) + ' \n ' + str (glob_files )
54+ if "" in files :
55+ files .remove ("" )
56+ files = [" file://" + os .path .abspath (f ) for f in files ]
57+ glob_files = expand_globs ("*" )
58+ assert set (files ) == glob_files , " \n " + str (set (files )) + " \n " + str (glob_files )
5459
5560 def testSupportedFormatChecking (self ):
5661 """
@@ -60,7 +65,7 @@ def testSupportedFormatChecking(self):
6065 """
6166
6267 for file_format , location in self .local .items ():
63- if file_format != ' unsupported' :
68+ if file_format != " unsupported" :
6469 # Tests the behavior after receiving supported file types with and without the 'file://' prefix
6570 self .assertEqual (wf_info (location ), self .expected [file_format ])
6671 self .assertEqual (wf_info (location [7 :]), self .expected [file_format ])
@@ -78,20 +83,24 @@ def testFileLocationChecking(self):
7883 """
7984
8085 for file_format , location in self .remote .items ():
81- if file_format == ' unsupported' :
86+ if file_format == " unsupported" :
8287 # Tests behavior after receiving a file hosted at an unsupported location.
8388 with self .assertRaises (NotImplementedError ):
8489 wf_info (location )
8590
86- elif file_format == ' unreachable' :
91+ elif file_format == " unreachable" :
8792 # Tests behavior after receiving a non-existent file.
8893 with self .assertRaises (IOError ):
8994 wf_info (location )
9095
9196 else :
9297 self .assertEqual (wf_info (location ), self .expected [file_format ])
93- self .assertFalse (os .path .isfile (os .path .join (os .getcwd (), 'fetchedFromRemote.' + file_format )))
98+ self .assertFalse (
99+ os .path .isfile (
100+ os .path .join (os .getcwd (), "fetchedFromRemote." + file_format )
101+ )
102+ )
94103
95104
96- if __name__ == ' __main__' :
105+ if __name__ == " __main__" :
97106 unittest .main () # run all tests
0 commit comments