def test_wait_for_running_error(mocks: Mocks, context: yogi.Context): """Checks the wait_for_running() function in the error case""" def fn(context, duration): assert -1 == duration return yogi.ErrorCode.UNKNOWN mocks.MOCK_ContextWaitForRunning(fn) with pytest.raises(yogi.FailureException): context.wait_for_running()
def test_wait_for_running_timeout(mocks: Mocks, context: yogi.Context): """Checks the wait_for_running() function in the timeout case""" def fn(context, duration): return yogi.ErrorCode.TIMEOUT mocks.MOCK_ContextWaitForRunning(fn) assert not context.wait_for_running(yogi.Duration.from_milliseconds(1))
def test_wait_for_running(mocks: Mocks, context: yogi.Context): """Checks the wait_for_running() function in the error-free case""" def fn(context, duration): assert context == 1234 assert 1000000 == duration return yogi.ErrorCode.OK mocks.MOCK_ContextWaitForRunning(fn) assert context.wait_for_running(yogi.Duration.from_milliseconds(1))