4
4
import subprocess
5
5
import sys
6
6
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
8
8
sys .path .insert (0 , pkg_root ) # noqa
9
9
10
10
from wes_client .util import expand_globs , wf_info
15
15
class IntegrationTest (unittest .TestCase ):
16
16
def setUp (self ):
17
17
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
+ }
23
25
24
26
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
+ }
35
40
36
41
def tearDown (self ):
37
42
unittest .TestCase .tearDown (self )
38
43
39
44
def test_expand_globs (self ):
40
45
"""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" , "." ])
42
47
43
48
# python 2/3 bytestring/utf-8 compatibility
44
49
if isinstance (files , str ):
45
- files = files .split (' \n ' )
50
+ files = files .split (" \n " )
46
51
else :
47
- files = files .decode (' utf-8' ).split (' \n ' )
52
+ files = files .decode (" utf-8" ).split (" \n " )
48
53
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 )
54
59
55
60
def testSupportedFormatChecking (self ):
56
61
"""
@@ -60,7 +65,7 @@ def testSupportedFormatChecking(self):
60
65
"""
61
66
62
67
for file_format , location in self .local .items ():
63
- if file_format != ' unsupported' :
68
+ if file_format != " unsupported" :
64
69
# Tests the behavior after receiving supported file types with and without the 'file://' prefix
65
70
self .assertEqual (wf_info (location ), self .expected [file_format ])
66
71
self .assertEqual (wf_info (location [7 :]), self .expected [file_format ])
@@ -78,20 +83,24 @@ def testFileLocationChecking(self):
78
83
"""
79
84
80
85
for file_format , location in self .remote .items ():
81
- if file_format == ' unsupported' :
86
+ if file_format == " unsupported" :
82
87
# Tests behavior after receiving a file hosted at an unsupported location.
83
88
with self .assertRaises (NotImplementedError ):
84
89
wf_info (location )
85
90
86
- elif file_format == ' unreachable' :
91
+ elif file_format == " unreachable" :
87
92
# Tests behavior after receiving a non-existent file.
88
93
with self .assertRaises (IOError ):
89
94
wf_info (location )
90
95
91
96
else :
92
97
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
+ )
94
103
95
104
96
- if __name__ == ' __main__' :
105
+ if __name__ == " __main__" :
97
106
unittest .main () # run all tests
0 commit comments