Beispiel #1
0
async def test_raises_on_unsupported_operations(starwars_schema):
    with pytest.raises(RuntimeError):
        subscribe(
            starwars_schema,
            parse("query { counter(delay: 0.001) }"),
            runtime=AsyncIORuntime(),
        )
Beispiel #2
0
async def test_raises_on_missing_subscription_resolver(starwars_schema):
    schema = subscription_schema(
        Field(
            "counter",
            NonNullType(Int),
            args=[Argument("delay", NonNullType(Float))],
            resolver=lambda event, *_, **__: event,
        )
    )

    with pytest.raises(RuntimeError):
        subscribe(
            schema,
            parse("subscription { counter(delay: 0.001) }"),
            runtime=AsyncIORuntime(),
        )
Beispiel #3
0
async def test_raises_on_unsupported_runtime():
    schema = subscription_schema(
        Field(
            "counter",
            NonNullType(Int),
            args=[Argument("delay", NonNullType(Float))],
            subscription_resolver=lambda *_, delay: AsyncCounter(delay, 10),
            resolver=lambda event, *_, **__: event,
        )
    )

    with pytest.raises(RuntimeError):
        subscribe(
            schema,
            parse("subscription { counter(delay: 0.001) }"),
            runtime=BlockingRuntime(),  # type: ignore
        )
Beispiel #4
0
async def test_raises_on_multiple_fields(starwars_schema):
    schema = subscription_schema(
        Field(
            "counter",
            NonNullType(Int),
            args=[Argument("delay", NonNullType(Float))],
            subscription_resolver=lambda *_, delay: AsyncCounter(delay, 10),
            resolver=lambda event, *_, **__: event,
        )
    )

    with pytest.raises(ExecutionError):
        subscribe(
            schema,
            parse(
                "subscription { counter(delay: 0.001), other: counter(delay: 0.001) }"
            ),
            runtime=AsyncIORuntime(),
        )