File: test_http_input.py

package info (click to toggle)
cwltool 1.0.20181217162649%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,632 kB
  • sloc: python: 11,008; makefile: 153; sh: 22
file content (26 lines) | stat: -rw-r--r-- 966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import tempfile

from cwltool.pathmapper import PathMapper


def test_http_path_mapping():
    class SubPathMapper(PathMapper):
        def __init__(self, referenced_files, basedir, stagedir):
            super(SubPathMapper, self).__init__(referenced_files, basedir, stagedir)
    input_file_path = "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta"
    tempdir = tempfile.mkdtemp()
    base_file = [{
        "class": "File",
        "location": "https://raw.githubusercontent.com/common-workflow-language/cwltool/master/tests/2.fasta",
        "basename": "chr20.fa"
    }]
    pathmap = SubPathMapper(base_file, os.getcwd(), tempdir)._pathmap

    assert input_file_path in pathmap
    assert os.path.exists(pathmap[input_file_path].resolved)

    with open(pathmap[input_file_path].resolved) as file:
        contents = file.read()

    assert ">Sequence 561 BP; 135 A; 106 C; 98 G; 222 T; 0 other;" in contents