1
1
import unittest
2
2
import os
3
+ import sys
4
+
5
+ pkg_root = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' )) # noqa
6
+ sys .path .insert (0 , pkg_root ) # noqa
7
+
3
8
from wes_client .util import wf_info
4
9
10
+
5
11
class WorkflowInfoTest (unittest .TestCase ):
6
12
7
- local = {'cwl' : 'file://' + os .path .join (os .getcwd () + '/workflow-service/ testdata/md5sum.cwl' ),
8
- 'wdl' : 'file://' + os .path .join (os .getcwd () + '/workflow-service/ testdata/md5sum.wdl' ),
9
- 'py' : 'file://' + os .path .join (os .getcwd () + '/workflow-service/ test/test_integration.py' ),
10
- 'unsupported' :'fake.txt' }
13
+ local = {'cwl' : 'file://' + os .path .join (os .getcwd () + '/testdata/md5sum.cwl' ),
14
+ 'wdl' : 'file://' + os .path .join (os .getcwd () + '/testdata/md5sum.wdl' ),
15
+ 'py' : 'file://' + os .path .join (os .getcwd () + '/test/test_integration.py' ),
16
+ 'unsupported' : 'fake.txt' }
11
17
12
- remote = {'cwl' :'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl' ,
13
- 'wdl' :'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl' ,
18
+ remote = {'cwl' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.cwl' ,
19
+ 'wdl' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/testdata/md5sum.wdl' ,
14
20
'py' : 'https://raw.githubusercontent.com/common-workflow-language/workflow-service/master/test/test_integration.py' ,
15
21
'unsupported' : 'gs://topmed_workflow_testing/topmed_aligner/small_test_files_sbg/example_human_known_snp.py' , # TODO: find real external file of .py, .cwl, .wdl
16
- 'unreachable' :'https://fake.py' }
22
+ 'unreachable' : 'https://fake.py' }
17
23
18
- expected = {'cwl' :('v1.0' , 'CWL' ),
19
- 'wdl' :('draft-2' ,'WDL' ),
24
+ expected = {'cwl' : ('v1.0' , 'CWL' ),
25
+ 'wdl' : ('draft-2' ,'WDL' ),
20
26
'py' : ('2.7' ,'PY' ),
21
- 'pyWithPrefix' : ('2.7' ,'PY' )}
27
+ 'pyWithPrefix' : ('2.7' ,'PY' )}
22
28
23
29
def testSupportedFormatChecking (self ):
24
- """Check that non-wdl, -python, -cwl files are rejected."""
30
+ """
31
+ Check that non-wdl, -python, -cwl files are rejected.
32
+
33
+ This test is run only on local files to avoid downloading and removing a new file.
34
+ """
25
35
26
- # The choice to run this on local files prevents the irrelevant steps of creating and removing a new file.
27
36
for format , location in self .local .items ():
28
37
if format != 'unsupported' :
29
38
# Tests the behavior after receiving supported file types with and without the 'file://' prefix
@@ -37,17 +46,23 @@ def testSupportedFormatChecking(self):
37
46
38
47
39
48
def testFileLocationChecking (self ):
40
- """Check that the function rejects unsupported file locations."""
41
- # This needs to be run on remote files to get to the location checking step.
49
+ """
50
+ Check that the function rejects unsupported file locations.
51
+
52
+ This test needs to be run on remote files to test the location checking functionality of wf_info().
53
+ """
54
+
42
55
for format , location in self .remote .items ():
43
56
if format == 'unsupported' :
44
- # Tests behavior after receiving a non-existant file.
57
+ # Tests behavior after receiving a file hosted at an unsupported location .
45
58
with self .assertRaises (NotImplementedError ):
46
59
wf_info (location )
60
+
47
61
elif format == 'unreachable' :
48
- # Tests behavior after receiving a non-existant file.
62
+ # Tests behavior after receiving a non-existent file.
49
63
with self .assertRaises (IOError ):
50
64
wf_info (location )
65
+
51
66
else :
52
67
self .assertEquals (wf_info (location ), self .expected [format ])
53
68
self .assertFalse (os .path .isfile (os .path .join (os .getcwd (), 'fetchedFromRemote.' + format )))
0 commit comments