Example #1
0
def test_wait_for_stopped_error(mocks: Mocks, context: yogi.Context):
    """Checks the wait_for_stopped() function in the error case"""
    def fn(context, duration):
        assert -1 == duration
        return yogi.ErrorCode.UNKNOWN

    mocks.MOCK_ContextWaitForStopped(fn)
    with pytest.raises(yogi.FailureException):
        context.wait_for_stopped()
Example #2
0
def test_wait_for_stopped_timeout(mocks: Mocks, context: yogi.Context):
    """Checks the wait_for_stopped() function in the timeout case"""
    def fn(context, duration):
        return yogi.ErrorCode.TIMEOUT

    mocks.MOCK_ContextWaitForStopped(fn)
    assert not context.wait_for_stopped(yogi.Duration.from_milliseconds(1))
Example #3
0
def test_wait_for_stopped(mocks: Mocks, context: yogi.Context):
    """Checks the wait_for_stopped() function in the error-free case"""
    def fn(context, duration):
        assert context == 1234
        assert 1000000 == duration
        return yogi.ErrorCode.OK

    mocks.MOCK_ContextWaitForStopped(fn)
    assert context.wait_for_stopped(yogi.Duration.from_milliseconds(1))