view env/lib/python3.7/site-packages/cwltool/tests/test_iwdr.py @ 4:79f47841a781 draft

"planemo upload commit 2a0fe2cc28b09e101d37293e53e82f61762262ec"
author shellac
date Thu, 14 May 2020 16:47:39 -0400
parents 26e78fe6e8c4
children
line wrap: on
line source

import tempfile
import os
from cwltool.main import main
from cwltool import load_tool
from .util import (get_data, get_windows_safe_factory, windows_needs_docker,
                   needs_docker, temp_dir, needs_singularity, get_main_output)

@windows_needs_docker
def test_newline_in_entry():
    """Files in a InitialWorkingDirectory are created with a newline character."""
    factory = get_windows_safe_factory()
    echo = factory.make(get_data("tests/wf/iwdr-entry.cwl"))
    assert echo(message="hello") == {"out": "CONFIGVAR=hello\n"}


@needs_docker
def test_empty_file_creation():
    """An empty file can be created in InitialWorkingDirectory."""
    err_code, _, _ = get_main_output([get_data("tests/wf/iwdr-empty.cwl")])
    assert err_code == 0


@needs_docker
def test_iwdr_permutations():
    saved_tempdir = tempfile.tempdir
    with temp_dir() as misc:
        tempfile.tempdir = os.path.realpath(misc)
        with temp_dir() as fifth:
    	    with temp_dir() as sixth:
    	        with temp_dir() as seventh:
    	            with temp_dir() as eighth:
    	                with tempfile.NamedTemporaryFile() as first:
    	                    with tempfile.NamedTemporaryFile() as second:
    	                        with tempfile.NamedTemporaryFile() as third:
    	                            with tempfile.NamedTemporaryFile() as fourth:
    	                                with temp_dir() as outdir:
    	                                    assert(main(
    	                                        ['--outdir', outdir,
    	                                         get_data("tests/wf/iwdr_permutations.cwl"),
    	                                         '--first', first.name,
    	                                         '--second', second.name,
    	                                         '--third', third.name,
    	                                         '--fourth', fourth.name,
    	                                         '--fifth', fifth,
    	                                         '--sixth', sixth,
    	                                         '--seventh', seventh,
    	                                         '--eighth', eighth]) == 0)
    tempfile.tempdir = saved_tempdir

@needs_docker
def test_iwdr_permutations_inplace():
    saved_tempdir = tempfile.tempdir
    with temp_dir() as misc:
        tempfile.tempdir = os.path.realpath(misc)
        with temp_dir() as fifth:
            with temp_dir() as sixth:
                with temp_dir() as seventh:
                    with temp_dir() as eighth:
                        with tempfile.NamedTemporaryFile() as first:
                            with tempfile.NamedTemporaryFile() as second:
                                with tempfile.NamedTemporaryFile() as third:
                                    with tempfile.NamedTemporaryFile() as fourth:
                                        with temp_dir() as outdir:
                                            assert(main(
                                                ['--outdir', outdir,
                                                 '--enable-ext',
                                                 '--overrides',
                                                 get_data("tests/wf/iwdr_permutations_inplace.yml"),
                                                 get_data("tests/wf/iwdr_permutations.cwl"),
                                                 '--first', first.name,
                                                 '--second', second.name,
                                                 '--third', third.name,
                                                 '--fourth', fourth.name,
                                                 '--fifth', fifth,
                                                 '--sixth', sixth,
                                                 '--seventh', seventh,
                                                 '--eighth', eighth]) == 0)
    tempfile.tempdir = saved_tempdir

@needs_singularity
def test_iwdr_permutations_singularity():
    with temp_dir() as fifth:
        with temp_dir() as sixth:
            with temp_dir() as seventh:
                with temp_dir() as eighth:
                    with tempfile.NamedTemporaryFile() as first:
                        with tempfile.NamedTemporaryFile() as second:
                            with tempfile.NamedTemporaryFile() as third:
                                with tempfile.NamedTemporaryFile() as fourth:
                                    with temp_dir() as outdir:
                                        assert(main(
                                            ['--outdir', outdir,
                                             '--singularity',
                                             get_data("tests/wf/iwdr_permutations.cwl"),
                                             '--first', first.name,
                                             '--second', second.name,
                                             '--third', third.name,
                                             '--fourth', fourth.name,
                                             '--fifth', fifth,
                                             '--sixth', sixth,
                                             '--seventh', seventh,
                                             '--eighth', eighth]) == 0)

@needs_singularity
def test_iwdr_permutations_singularity_inplace():
    with temp_dir() as fifth:
        with temp_dir() as sixth:
            with temp_dir() as seventh:
                with temp_dir() as eighth:
                    with tempfile.NamedTemporaryFile() as first:
                        with tempfile.NamedTemporaryFile() as second:
                            with tempfile.NamedTemporaryFile() as third:
                                with tempfile.NamedTemporaryFile() as fourth:
                                    with temp_dir() as outdir:
                                        assert(main(
                                            ['--outdir', outdir,
                                             '--singularity',
                                             '--enable-ext',
                                             '--overrides',
                                             get_data("tests/wf/iwdr_permutations_inplace.yml"),
                                             get_data("tests/wf/iwdr_permutations.cwl"),
                                             '--first', first.name,
                                             '--second', second.name,
                                             '--third', third.name,
                                             '--fourth', fourth.name,
                                             '--fifth', fifth,
                                             '--sixth', sixth,
                                             '--seventh', seventh,
                                             '--eighth', eighth]) == 0)