From b2ee9388123a8431008a740218e9a2ad675b1398 Mon Sep 17 00:00:00 2001 From: Ketan Umare <16888709+kumare3@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:33:03 -0700 Subject: [PATCH] Added a missing test for != `ne` condition (#443) * Added a missing test for != `ne` condition Signed-off-by: Ketan Umare * improved the test to use previous task output Signed-off-by: Ketan Umare Signed-off-by: Max Hoffman --- tests/flytekit/unit/core/test_type_hints.py | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/flytekit/unit/core/test_type_hints.py b/tests/flytekit/unit/core/test_type_hints.py index 271cc3cd62..4590bfb1b8 100644 --- a/tests/flytekit/unit/core/test_type_hints.py +++ b/tests/flytekit/unit/core/test_type_hints.py @@ -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(): @@ -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(): @@ -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):