def test_continue_running_actions_with_asserts_first_run(): actions = [Action(name="bar", asserts=[Assert(name="foo")])] asserts = [] assert testing.continue_running( actions=actions, asserts=asserts, remaining_cycles=-1, actions_data={}, assert_statuses={}, )
def run_assert_from_action_result(asrt: Assert, action_result: ActionResult): if asrt.get("type") == "NullAssert": assert_result = AssertResult( passed=asrt.get("passed", False), actual=asrt.get("actual", ""), expected=asrt.get("expected", ""), description=asrt.get("description", ""), ) else: assert ( "expected" in asrt ), f"Assert {asrt.get('name')} is missing property 'expected'" actual = asrt.get("actual", action_result) expected = asrt.get("expected") passed, description = assert_element( expected, actual, **asrt.get("assertOptions", {}) ) if asrt.get("negate", False): passed = not passed if passed: description = f"passed; negated: {description}" else: description = f"expected not {expected}" assert_result = AssertResult( passed=passed, actual=actual, expected=expected, description=description, ) return assert_result
def test_continue_running_actions_with_asserts_failed_limited_second_run(): actions = [Action(name="bar", asserts=[Assert(name="foo")])] asserts = [] actions_data = { "bar": { "asserts": { "foo": AssertResult(passed=False, actual="", expected="", description="") } } } assert not testing.continue_running( actions=actions, asserts=asserts, remaining_cycles=0, actions_data=actions_data, assert_statuses={}, )
def test_get_default_cycles_actions_have_asserts(): default_cycles = testing.get_default_cycles( asserts=[], actions=[Action(name="bar", asserts=[Assert(name="foo")])]) assert default_cycles == -1
def test_get_default_cycles_asserts_only(): default_cycles = testing.get_default_cycles(asserts=[Assert(name="foo")], actions=[]) assert default_cycles == -1