comparison env/lib/python3.7/site-packages/cwltool/tests/test_subgraph.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 import os
2
3 from six.moves import urllib
4
5 import pytest
6 import json
7
8 from cwltool.context import LoadingContext
9 from cwltool.load_tool import load_tool
10 from cwltool.workflow import default_make_tool
11 from cwltool.subgraph import get_subgraph
12 from schema_salad.utils import convert_to_dict
13 from cwltool.resolver import Path, resolve_local
14 from .util import get_data, working_directory
15 from six import string_types
16 from .test_fetch import norm
17
18 def test_get_subgraph():
19 loadingContext = LoadingContext({"construct_tool_object": default_make_tool})
20 wf = norm(Path(get_data("tests/subgraph/count-lines1-wf.cwl")).as_uri())
21 loadingContext.do_update = False
22 tool = load_tool(wf, loadingContext)
23
24 sg = norm(Path(get_data("tests/subgraph")).as_uri())
25
26 def clean(val):
27 if isinstance(val, string_types):
28 if val.startswith(sg):
29 return val[len(sg)+1:]
30 if isinstance(val, dict):
31 return {k: clean(v) for k,v in val.items()}
32 if isinstance(val, list):
33 return [clean(v) for v in val]
34 return val
35
36 for a in ("file1", "file2", "file3", "count_output",
37 "output3", "output4", "output5",
38 "step1", "step2", "step3", "step4", "step5"):
39 extracted = get_subgraph([wf+"#"+a], tool)
40 with open(get_data("tests/subgraph/extract_"+a+".json")) as f:
41 assert json.load(f) == clean(convert_to_dict(extracted))