Mercurial > repos > shellac > guppy_basecaller
diff env/lib/python3.7/site-packages/cwltool/tests/test_subgraph.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/lib/python3.7/site-packages/cwltool/tests/test_subgraph.py Thu May 14 14:56:58 2020 -0400 @@ -0,0 +1,41 @@ +import os + +from six.moves import urllib + +import pytest +import json + +from cwltool.context import LoadingContext +from cwltool.load_tool import load_tool +from cwltool.workflow import default_make_tool +from cwltool.subgraph import get_subgraph +from schema_salad.utils import convert_to_dict +from cwltool.resolver import Path, resolve_local +from .util import get_data, working_directory +from six import string_types +from .test_fetch import norm + +def test_get_subgraph(): + loadingContext = LoadingContext({"construct_tool_object": default_make_tool}) + wf = norm(Path(get_data("tests/subgraph/count-lines1-wf.cwl")).as_uri()) + loadingContext.do_update = False + tool = load_tool(wf, loadingContext) + + sg = norm(Path(get_data("tests/subgraph")).as_uri()) + + def clean(val): + if isinstance(val, string_types): + if val.startswith(sg): + return val[len(sg)+1:] + if isinstance(val, dict): + return {k: clean(v) for k,v in val.items()} + if isinstance(val, list): + return [clean(v) for v in val] + return val + + for a in ("file1", "file2", "file3", "count_output", + "output3", "output4", "output5", + "step1", "step2", "step3", "step4", "step5"): + extracted = get_subgraph([wf+"#"+a], tool) + with open(get_data("tests/subgraph/extract_"+a+".json")) as f: + assert json.load(f) == clean(convert_to_dict(extracted))