def test_run_one_error(mocks: Mocks, context: yogi.Context): """Checks the run_one() function in the error case""" def fn(context, count, duration): assert -1 == duration return yogi.ErrorCode.UNKNOWN mocks.MOCK_ContextRunOne(fn) with pytest.raises(yogi.FailureException): context.run_one()
def test_run_one(mocks: Mocks, context: yogi.Context): """Checks the run_one() function in the error-free case""" def fn(context, count, duration): assert context == 1234 assert count assert 1000000 == duration count.contents.value = 1 return yogi.ErrorCode.OK mocks.MOCK_ContextRunOne(fn) assert context.run_one(yogi.Duration.from_milliseconds(1)) == 1