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

    mocks.MOCK_ContextRun(fn)
    with pytest.raises(yogi.FailureException):
        context.run()
Example #2
0
def test_run(mocks: Mocks, context: yogi.Context):
    """Checks the run() function in the error-free case"""
    def fn(context, count, duration):
        assert context == 1234
        assert count
        assert 1000000 == duration
        count.contents.value = 5
        return yogi.ErrorCode.OK

    mocks.MOCK_ContextRun(fn)
    assert context.run(yogi.Duration.from_milliseconds(1)) == 5