Skip to content

Commit

Permalink
feat: Added a test for default renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
KamenDimitrov97 committed Sep 30, 2024
1 parent b6677c0 commit 2fa4145
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions tests/test_render_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,20 @@ def test_can_load_render_module() -> None:
""",
}


def test_can_load_cwl_render_module() -> None:
"""Checks if we can load a render module."""
result = triple_and_one(num=increment(num=3))
workflow = construct(result, simplify_ids=True)
workflow._name = "Fred"

frender_py = Path(__file__).parent.parent / "src/dewret/renderers/cwl.py"
render = get_render_method(frender_py)
assert yaml.safe_load(render(workflow)["__root__"]) == yaml.safe_load("""
cwlVersion: 1.2
class: Workflow
inputs:
increment-1-num:
label: num
type: int
default: 3
outputs:
out:
label: out
type: [int, float]
outputSource: triple_and_one-1/out
steps:
increment-1:
run: increment
in:
num:
source: increment-1-num
out: [out]
triple_and_one-1:
run: triple_and_one
in:
num:
source: increment-1/out
out: [out]
""")

assert render(workflow) == {
"__root__": "{'cwlVersion': 1.2, 'class': 'Workflow', 'inputs': {'increment-1-num': {'label': 'num', 'type': 'int', 'default': 3}}, 'outputs': {'out': {'label': 'out', 'type': ['int', 'float'], 'outputSource': 'triple_and_one-1/out'}}, 'steps': {'increment-1': {'run': 'increment', 'in': {'num': {'source': 'increment-1-num'}}, 'out': ['out']}, 'triple_and_one-1': {'run': 'triple_and_one', 'in': {'num': {'source': 'increment-1/out'}}, 'out': ['out']}}}",
"triple_and_one-1": "{'cwlVersion': 1.2, 'class': 'Workflow', 'inputs': {'num': {'label': 'num', 'type': 'int'}}, 'outputs': {'out': {'label': 'out', 'type': ['int', 'float'], 'outputSource': 'sum-1-1/out'}}, 'steps': {'double-1-1': {'run': 'double', 'in': {'num': {'source': 'num'}}, 'out': ['out']}, 'sum-1-1': {'run': 'sum', 'in': {'left': {'source': 'sum-1-2/out'}, 'right': {'default': 1}}, 'out': ['out']}, 'sum-1-2': {'run': 'sum', 'in': {'left': {'source': 'double-1-1/out'}, 'right': {'source': 'num'}}, 'out': ['out']}}}"
}


def test_get_correct_import_error_if_unable_to_load_render_module() -> None:
"""Check if the correct import error will be logged if unable to load render module."""
unfrender_py = Path(__file__).parent / "_lib/unfrender.py"
Expand Down

0 comments on commit 2fa4145

Please sign in to comment.