Skip to content

Commit

Permalink
Added a missing test for != ne condition (flyteorg#443)
Browse files Browse the repository at this point in the history
* Added a missing test for != `ne` condition

Signed-off-by: Ketan Umare <[email protected]>

* improved the test to use previous task output

Signed-off-by: Ketan Umare <[email protected]>
  • Loading branch information
kumare3 authored Apr 7, 2021
1 parent cef8a23 commit 3d3f8ef
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/flytekit/unit/core/test_type_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ def print_expr(expr):
print_expr(((px == py) & (px < py)) | (px > py))
print_expr(px < 5)
print_expr(px >= 5)
print_expr(px != 5)


def test_comparison_lits():
Expand All @@ -478,6 +479,8 @@ def eval_expr(expr, expected: bool):
eval_expr(px < 5, False)
eval_expr(px >= 5, True)
eval_expr(py >= 5, True)
eval_expr(py != 5, True)
eval_expr(px != 5, False)


def test_wf1_branches():
Expand Down Expand Up @@ -511,6 +514,27 @@ def my_wf(a: int, b: str) -> (int, str):
assert x == (4, "It is hello")


def test_wf1_branches_ne():
@task
def t1(a: int) -> int:
return a + 1

@task
def t2(a: str) -> str:
return a

@workflow
def my_wf(a: int, b: str) -> str:
new_a = t1(a=a)
return conditional("test1").if_(new_a != 5).then(t2(a=b)).else_().fail("Unable to choose branch")

with pytest.raises(ValueError):
my_wf(a=4, b="hello")

x = my_wf(a=5, b="hello")
assert x == "hello"


def test_wf1_branches_no_else():
with pytest.raises(NotImplementedError):

Expand Down

0 comments on commit 3d3f8ef

Please sign in to comment.