def test_check_until_never(): with pytest.raises(jgt_common.IncompleteAtTimeoutException) as e: jgt_common.check_until( cycle_func, jgt_common.always_false, timeout=CHECK_UNTIL_TIMEOUT, cycle_secs=CHECK_UNTIL_CYCLE_SECS, ) assert e.call_result in CYCLE_ITEMS assert e.timeout == CHECK_UNTIL_TIMEOUT
def test_check_until_function_call_is_only_invoked_once_if_first_call_succeeds( ): call_log = [] arbitrary_but_non_trivial_timeout = 10 arbitrary_but_non_trivial_cycle_secs = 1 arbitrary_fn_args = (1, ) jgt_common.check_until( call_log.append, lambda *args: True, fn_args=arbitrary_fn_args, timeout=arbitrary_but_non_trivial_timeout, cycle_secs=arbitrary_but_non_trivial_cycle_secs, ) assert (len(call_log) == 1 ), "check_until invoked function_call the wrong number of times!"
def test_check_until_pass(): assert (jgt_common.check_until( cycle_func, is_final_number, timeout=CHECK_UNTIL_TIMEOUT, cycle_secs=CHECK_UNTIL_CYCLE_SECS, ) == CYCLE_ITEMS[-1])