def test_post(mocks: Mocks, context: yogi.Context): """Checks the post() function in the error-free case""" def fn(context, fn, userarg): assert context == 1234 assert fn fn(userarg) return yogi.ErrorCode.OK mocks.MOCK_ContextPost(fn) called = False def handlerFn(): nonlocal called called = True context.post(handlerFn) assert called
def test_post_error(mocks: Mocks, context: yogi.Context): """Checks the post_error() function in the error case""" mocks.MOCK_ContextPost(lambda *_: yogi.ErrorCode.WRONG_OBJECT_TYPE) with pytest.raises(yogi.FailureException): context.post(lambda: None)