Skip to content

Commit 537d278

Browse files
author
Peter Amstutz
committed
Add tests for version check and metadata behavior
1 parent 7682370 commit 537d278

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/test_load_tool.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)