Beispiel #1
0
async def test_services_from_normalization():
    app_services = Services()

    def handler(services):
        assert services is app_services
        return None

    method = normalize_handler(Route(b"/", handler), app_services)
    await method(None)
Beispiel #2
0
    def normalize_handlers(self):
        configured_handlers = set()

        for route in self.router:
            if route.handler in configured_handlers:
                continue

            route.handler = normalize_handler(route, self.services)

            configured_handlers.add(route.handler)
        configured_handlers.clear()
Beispiel #3
0
async def test_services_from_normalization():

    app_services = {}

    def handler(services):
        assert services is app_services
        return services

    method = normalize_handler(Route(b'/', handler), app_services)
    services = await method(None)
    assert services is app_services
Beispiel #4
0
def test_raises_for_unsupported_signature():
    app_services = Services()

    def handler(services, *args):
        assert services is app_services
        return services

    def handler2(services, **kwargs):
        assert services is app_services
        return services

    def handler3(services, *, key_only):
        assert services is app_services
        return services

    with pytest.raises(UnsupportedSignatureError):
        normalize_handler(Route(b"/", handler), Services())

    with pytest.raises(UnsupportedSignatureError):
        normalize_handler(Route(b"/", handler2), Services())

    with pytest.raises(UnsupportedSignatureError):
        normalize_handler(Route(b"/", handler3), Services())