|
| 1 | +from cwltool.load_tool import load_tool |
| 2 | +from cwltool.context import LoadingContext, RuntimeContext |
| 3 | +from cwltool.errors import WorkflowException |
| 4 | +import pytest |
| 5 | +from .util import (get_data, get_main_output, |
| 6 | + get_windows_safe_factory, |
| 7 | + needs_docker, working_directory, |
| 8 | + needs_singularity, temp_dir, |
| 9 | + windows_needs_docker) |
| 10 | + |
| 11 | +@windows_needs_docker |
| 12 | +def test_check_version(): |
| 13 | + """Test that it is permitted to load without updating, but not |
| 14 | + execute. Attempting to execute without updating to the internal |
| 15 | + version should raise an error. |
| 16 | +
|
| 17 | + """ |
| 18 | + |
| 19 | + joborder = {"inp": "abc"} |
| 20 | + loadingContext = LoadingContext({"do_update": True}) |
| 21 | + tool = load_tool(get_data("tests/echo.cwl"), loadingContext) |
| 22 | + for j in tool.job(joborder, None, RuntimeContext()): |
| 23 | + pass |
| 24 | + |
| 25 | + loadingContext = LoadingContext({"do_update": False}) |
| 26 | + tool = load_tool(get_data("tests/echo.cwl"), loadingContext) |
| 27 | + with pytest.raises(WorkflowException): |
| 28 | + for j in tool.job(joborder, None, RuntimeContext()): |
| 29 | + pass |
| 30 | + |
| 31 | +def test_use_metadata(): |
| 32 | + """Test that it will use the version from loadingContext.metadata if |
| 33 | + cwlVersion isn't present in the document. |
| 34 | +
|
| 35 | + """ |
| 36 | + |
| 37 | + loadingContext = LoadingContext({"do_update": False}) |
| 38 | + tool = load_tool(get_data("tests/echo.cwl"), loadingContext) |
| 39 | + |
| 40 | + loadingContext = LoadingContext() |
| 41 | + loadingContext.metadata = tool.metadata |
| 42 | + tooldata = tool.tool.copy() |
| 43 | + del tooldata["cwlVersion"] |
| 44 | + tool2 = load_tool(tooldata, loadingContext) |
0 commit comments