Skip to content

Commit c77aa75

Browse files
committed
Run DjangDebugMiddleware tests asynchronously
1 parent 78e510b commit c77aa75

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

graphene_django/debug/tests/test_query.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class context(object):
1515

1616
# from examples.starwars_django.models import Character
1717

18-
pytestmark = pytest.mark.django_db
18+
pytestmark = [pytest.mark.django_db, pytest.mark.asyncio]
1919

2020

21-
def test_should_query_field():
21+
async def test_should_query_field():
2222
r1 = Reporter(last_name="ABA")
2323
r1.save()
2424
r2 = Reporter(last_name="Griffin")
@@ -53,14 +53,14 @@ def resolve_reporter(self, info, **args):
5353
"_debug": {"sql": [{"rawSql": str(Reporter.objects.order_by("pk")[:1].query)}]},
5454
}
5555
schema = graphene.Schema(query=Query)
56-
result = schema.execute(
56+
result = await schema.execute_async(
5757
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
5858
)
5959
assert not result.errors
6060
assert result.data == expected
6161

6262

63-
def test_should_query_nested_field():
63+
async def test_should_query_nested_field():
6464
r1 = Reporter(last_name="ABA")
6565
r1.save()
6666
r2 = Reporter(last_name="Griffin")
@@ -112,7 +112,7 @@ def resolve_reporter(self, info, **args):
112112
}
113113
}
114114
schema = graphene.Schema(query=Query)
115-
result = schema.execute(
115+
result = await schema.execute_async(
116116
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
117117
)
118118
assert not result.errors
@@ -127,7 +127,7 @@ def resolve_reporter(self, info, **args):
127127
assert result.data["reporter"] == expected["reporter"]
128128

129129

130-
def test_should_query_list():
130+
async def test_should_query_list():
131131
r1 = Reporter(last_name="ABA")
132132
r1.save()
133133
r2 = Reporter(last_name="Griffin")
@@ -162,14 +162,14 @@ def resolve_all_reporters(self, info, **args):
162162
"_debug": {"sql": [{"rawSql": str(Reporter.objects.all().query)}]},
163163
}
164164
schema = graphene.Schema(query=Query)
165-
result = schema.execute(
165+
result = await schema.execute_async(
166166
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
167167
)
168168
assert not result.errors
169169
assert result.data == expected
170170

171171

172-
def test_should_query_connection():
172+
async def test_should_query_connection():
173173
r1 = Reporter(last_name="ABA")
174174
r1.save()
175175
r2 = Reporter(last_name="Griffin")
@@ -205,7 +205,7 @@ def resolve_all_reporters(self, info, **args):
205205
"""
206206
expected = {"allReporters": {"edges": [{"node": {"lastName": "ABA"}}]}}
207207
schema = graphene.Schema(query=Query)
208-
result = schema.execute(
208+
result = await schema.execute_async(
209209
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
210210
)
211211
assert not result.errors
@@ -215,7 +215,7 @@ def resolve_all_reporters(self, info, **args):
215215
assert result.data["_debug"]["sql"][1]["rawSql"] == query
216216

217217

218-
def test_should_query_connectionfilter():
218+
async def test_should_query_connectionfilter():
219219
from ...filter import DjangoFilterConnectionField
220220

221221
r1 = Reporter(last_name="ABA")
@@ -254,7 +254,7 @@ def resolve_all_reporters(self, info, **args):
254254
"""
255255
expected = {"allReporters": {"edges": [{"node": {"lastName": "ABA"}}]}}
256256
schema = graphene.Schema(query=Query)
257-
result = schema.execute(
257+
result = await schema.execute_async(
258258
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
259259
)
260260
assert not result.errors

0 commit comments

Comments
 (0)