Skip to content

Commit 373400f

Browse files
committed
Revert "add an async context getter for tests which is easily patchable."
This reverts commit 6198007.
1 parent c074e09 commit 373400f

File tree

6 files changed

+10
-25
lines changed

6 files changed

+10
-25
lines changed

tests/http/clients/aiohttp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from strawberry.types import ExecutionResult
1717
from tests.views.schema import Query, schema
1818

19-
from ..context import get_context_async as get_context
19+
from ..context import get_context
2020
from .base import (
2121
JSON,
2222
DebuggableGraphQLTransportWSHandler,
@@ -39,7 +39,7 @@ async def get_context(
3939
) -> object:
4040
context = await super().get_context(request, response)
4141

42-
return await get_context(context)
42+
return get_context(context)
4343

4444
async def get_root_value(self, request: web.Request) -> Query:
4545
await super().get_root_value(request) # for coverage

tests/http/clients/asgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from strawberry.types import ExecutionResult
1818
from tests.views.schema import Query, schema
1919

20-
from ..context import get_context_async as get_context
20+
from ..context import get_context
2121
from .base import (
2222
JSON,
2323
DebuggableGraphQLTransportWSHandler,
@@ -45,7 +45,7 @@ async def get_context(
4545
) -> object:
4646
context = await super().get_context(request, response)
4747

48-
return await get_context(context)
48+
return get_context(context)
4949

5050
async def process_result(
5151
self, request: Request, result: ExecutionResult

tests/http/clients/channels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from strawberry.http.typevars import Context, RootValue
2121
from tests.views.schema import Query, schema
2222

23-
from ..context import get_context, get_context_async
23+
from ..context import get_context
2424
from .base import (
2525
JSON,
2626
DebuggableGraphQLTransportWSHandler,
@@ -78,7 +78,7 @@ async def get_root_value(self, request: ChannelsConsumer) -> Optional[RootValue]
7878
async def get_context(self, request: ChannelsConsumer, response: Any) -> Context:
7979
context = await super().get_context(request, response)
8080

81-
return await get_context_async(context)
81+
return get_context(context)
8282

8383
async def process_result(
8484
self, request: ChannelsConsumer, result: Any

tests/http/clients/fastapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from strawberry.types import ExecutionResult
1717
from tests.views.schema import Query, schema
1818

19-
from ..context import get_context_async as get_context
19+
from ..context import get_context
2020
from .asgi import AsgiWebSocketClient
2121
from .base import (
2222
JSON,
@@ -39,7 +39,7 @@ async def fastapi_get_context(
3939
ws: WebSocket = None, # type: ignore
4040
custom_value: str = Depends(custom_context_dependency),
4141
) -> Dict[str, object]:
42-
return await get_context(
42+
return get_context(
4343
{
4444
"request": request or ws,
4545
"background_tasks": background_tasks,

tests/http/clients/litestar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from strawberry.types import ExecutionResult
1717
from tests.views.schema import Query, schema
1818

19-
from ..context import get_context_async as get_context
19+
from ..context import get_context
2020
from .base import (
2121
JSON,
2222
DebuggableGraphQLTransportWSHandler,
@@ -30,7 +30,7 @@
3030

3131

3232
async def litestar_get_context(request: Request = None):
33-
return await get_context({"request": request})
33+
return get_context({"request": request})
3434

3535

3636
async def get_root_value(request: Request = None):

tests/http/context.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22

33

44
def get_context(context: object) -> Dict[str, object]:
5-
return get_context_inner(context)
6-
7-
8-
# a patchable method for unittests
9-
def get_context_inner(context: object) -> Dict[str, object]:
105
assert isinstance(context, dict)
11-
return {**context, "custom_value": "a value from context"}
12-
136

14-
# async version for async frameworks
15-
async def get_context_async(context: object) -> Dict[str, object]:
16-
return await get_context_async_inner(context)
17-
18-
19-
# a patchable method for unittests
20-
async def get_context_async_inner(context: object) -> Dict[str, object]:
21-
assert isinstance(context, dict)
227
return {**context, "custom_value": "a value from context"}

0 commit comments

Comments
 (0)