예제 #1
0
def test_middleware_holds_state_across_requests():
    provider = BaseProvider()

    manager = RequestManager(None, provider, middlewares=[stateful_middleware])
    state_a = manager.request_blocking('test_statefulness', [])
    assert len(state_a) == 1

    state_b = manager.request_blocking('test_statefulness', [])

    assert id(state_a) == id(state_b)
    assert len(state_b) == 2
def test_provider_property_setter_and_getter(middleware_factory):
    middleware_a = middleware_factory('middleware-A')
    middleware_b = middleware_factory('middleware-B')

    provider = DummyProvider()

    manager = RequestManager(None,
                             provider,
                             middlewares=[middleware_a, middleware_b])
    response = manager.request_blocking('init', ['init'])

    assert response['method'] == 'init|middleware-A|middleware-B'
    assert response['params'] == ['init', 'middleware-A', 'middleware-B']
    assert response['middlewares'] == ['middleware-B', 'middleware-A']