Skip to content

Commit

Permalink
test: pull out bad render test into its own function and add another …
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
edufnt committed Oct 11, 2024
1 parent 4c4e0ee commit 82ca200
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from ._lib.extra import increment, sum, try_nothing

from typing import Any

ARG1: AtRender[bool] = True
ARG2: bool = False

Expand Down Expand Up @@ -37,6 +39,12 @@ def to_int_bad(num: int, should_double: bool) -> int | float:
return increment(num=num) if should_double else sum(left=num, right=num)


@workflow()
def to_int_bad_2(num: int, should_double: Any) -> int | float:
"""A mock workflow that casts to an int with a wrong type for handling doubles."""
return increment(num=num) if should_double else sum(left=num, right=num)


@workflow()
def to_int(num: int, should_double: AtRender[bool]) -> int | float:
"""A mock workflow that casts to an int with a right type for handling doubles."""
Expand Down Expand Up @@ -76,12 +84,18 @@ def test_can_analyze_annotations() -> None:
assert analyser.argument_has("ARG1", AtRender) is False


def test_at_render() -> None:
"""Test the rendering of workflows with `dewret.annotations.AtRender` and exceptions handling."""
def test_at_render_bad() -> None:
"""Test the rendering of workflows with exceptions handling."""
with pytest.raises(TaskException) as _:
result = to_int_bad(num=increment(num=3), should_double=True)
wkflw = construct(result, simplify_ids=True)
with pytest.raises(TaskException) as _:
result = to_int_bad_2(num=increment(num=3), should_double=True)
wkflw = construct(result, simplify_ids=True)


def test_at_render() -> None:
"""Test the rendering of workflows with `dewret.annotations.AtRender`."""
result = to_int(num=increment(num=3), should_double=True)
wkflw = construct(result, simplify_ids=True)
subworkflows = render(wkflw, allow_complex_types=True)
Expand Down

0 comments on commit 82ca200

Please sign in to comment.