From eb8c340cf870a49342061e0363b29e691ec62028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Thu, 8 Jun 2023 11:33:36 +0000 Subject: [PATCH] undo change to tests --- tests/schema/test_permission.py | 1 + tests/schema/test_subscription.py | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/schema/test_permission.py b/tests/schema/test_permission.py index aade03ec3f..fe8a23ac07 100644 --- a/tests/schema/test_permission.py +++ b/tests/schema/test_permission.py @@ -76,6 +76,7 @@ async def user(self, info) -> typing.AsyncGenerator[str, None]: query = "subscription { user }" result = await schema.subscribe(query) + assert result.errors[0].message == "You are not authorized" diff --git a/tests/schema/test_subscription.py b/tests/schema/test_subscription.py index 95191d0192..c3b700a3e5 100644 --- a/tests/schema/test_subscription.py +++ b/tests/schema/test_subscription.py @@ -25,9 +25,11 @@ async def example(self) -> typing.AsyncGenerator[str, None]: query = "subscription { example }" - async for result in await schema.subscribe(query): - assert not result.errors - assert result.data["example"] == "Hi" + sub = await schema.subscribe(query) + result = await sub.__anext__() + + assert not result.errors + assert result.data["example"] == "Hi" @pytest.mark.asyncio @@ -46,9 +48,11 @@ async def example(self, name: str) -> typing.AsyncGenerator[str, None]: query = 'subscription { example(name: "Nina") }' - async for result in await schema.subscribe(query): - assert not result.errors - assert result.data["example"] == "Hi Nina" + sub = await schema.subscribe(query) + result = await sub.__anext__() + + assert not result.errors + assert result.data["example"] == "Hi Nina" requires_builtin_generics = pytest.mark.skipif( @@ -87,6 +91,8 @@ class Subscription: query = "subscription { example }" - async for result in await schema.subscribe(query): - assert not result.errors - assert result.data["example"] == "Hi" + sub = await schema.subscribe(query) + result = await sub.__anext__() + + assert not result.errors + assert result.data["example"] == "Hi"