|
1 |
| -from __future__ import absolute_import |
2 |
| - |
3 | 1 | import os
|
4 | 2 | import tempfile
|
5 |
| -import unittest |
6 | 3 |
|
7 | 4 | from cwltool.pathmapper import PathMapper
|
8 | 5 |
|
9 | 6 |
|
10 |
| -class TestHttpInput(unittest.TestCase): |
11 |
| - def test_http_path_mapping(self): |
12 |
| - class SubPathMapper(PathMapper): |
13 |
| - def __init__(self, referenced_files, basedir, stagedir): |
14 |
| - super(SubPathMapper, self).__init__(referenced_files, basedir, stagedir) |
15 |
| - input_file_path = "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta" |
16 |
| - tempdir = tempfile.mkdtemp() |
17 |
| - base_file = [{ |
18 |
| - "class": "File", |
19 |
| - "location": "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta", |
20 |
| - "basename": "chr20.fa" |
21 |
| - }] |
22 |
| - path_map_obj = SubPathMapper(base_file, os.getcwd(), tempdir) |
| 7 | +def test_http_path_mapping(): |
| 8 | + class SubPathMapper(PathMapper): |
| 9 | + def __init__(self, referenced_files, basedir, stagedir): |
| 10 | + super(SubPathMapper, self).__init__(referenced_files, basedir, stagedir) |
| 11 | + input_file_path = "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta" |
| 12 | + tempdir = tempfile.mkdtemp() |
| 13 | + base_file = [{ |
| 14 | + "class": "File", |
| 15 | + "location": "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta", |
| 16 | + "basename": "chr20.fa" |
| 17 | + }] |
| 18 | + pathmap = SubPathMapper(base_file, os.getcwd(), tempdir)._pathmap |
| 19 | + |
| 20 | + assert input_file_path in pathmap |
| 21 | + assert os.path.exists(pathmap[input_file_path].resolved) |
| 22 | + |
| 23 | + with open(pathmap[input_file_path].resolved) as file: |
| 24 | + contents = file.read() |
23 | 25 |
|
24 |
| - self.assertIn(input_file_path,path_map_obj._pathmap) |
25 |
| - assert os.path.exists(path_map_obj._pathmap[input_file_path].resolved) == 1 |
26 |
| - with open(path_map_obj._pathmap[input_file_path].resolved) as f: |
27 |
| - self.assertIn(">Sequence 561 BP; 135 A; 106 C; 98 G; 222 T; 0 other;",f.read()) |
28 |
| - f.close() |
| 26 | + assert ">Sequence 561 BP; 135 A; 106 C; 98 G; 222 T; 0 other;" in contents |
0 commit comments