Skip to content

Commit c4d0b05

Browse files
committed
cleanup
1 parent 373400f commit c4d0b05

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

RELEASE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Release type: patch
22

3-
Operations over `graphql-transport-ws` now create the Context and perform validation on
4-
the worker `Task`, thus not blocking the websocket from accepting messages.
3+
Fix error handling for query operations over graphql-transport-ws

tests/http/clients/litestar.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
)
3030

3131

32+
def custom_context_dependency() -> str:
33+
return "Hi!"
34+
35+
3236
async def litestar_get_context(request: Request = None):
3337
return get_context({"request": request})
3438

tests/views/schema.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class DebugInfo:
7777
@strawberry.type
7878
class Query:
7979
@strawberry.field
80-
def greetings(self) -> str: # pragma: no cover
80+
def greetings(self) -> str:
8181
return "hello"
8282

8383
@strawberry.field
@@ -91,13 +91,13 @@ async def async_hello(self, name: Optional[str] = None, delay: float = 0) -> str
9191

9292
@strawberry.field(permission_classes=[AlwaysFailPermission])
9393
def always_fail(self) -> Optional[str]:
94-
return "Hey" # pragma: no cover
94+
return "Hey"
9595

9696
@strawberry.field(permission_classes=[ConditionalFailPermission])
9797
def conditional_fail(
9898
self, sleep: Optional[float] = None, fail: bool = False
9999
) -> str:
100-
return "Hey" # pragma: no cover
100+
return "Hey"
101101

102102
@strawberry.field
103103
async def error(self, message: str) -> AsyncGenerator[str, None]:
@@ -108,7 +108,7 @@ async def exception(self, message: str) -> str:
108108
raise ValueError(message)
109109

110110
@strawberry.field
111-
def teapot(self, info: strawberry.Info[Any, None]) -> str: # pragma: no cover
111+
def teapot(self, info: strawberry.Info[Any, None]) -> str:
112112
info.context["response"].status_code = 418
113113

114114
return "🫖"
@@ -142,7 +142,7 @@ def set_header(self, info: strawberry.Info, name: str) -> str:
142142
@strawberry.type
143143
class Mutation:
144144
@strawberry.mutation
145-
def echo(self, string_to_echo: str) -> str: # pragma: no cover
145+
def echo(self, string_to_echo: str) -> str:
146146
return string_to_echo
147147

148148
@strawberry.mutation
@@ -162,7 +162,7 @@ def read_folder(self, folder: FolderInput) -> List[str]:
162162
return list(map(_read_file, folder.files))
163163

164164
@strawberry.mutation
165-
def match_text(self, text_file: Upload, pattern: str) -> str: # pragma: no cover
165+
def match_text(self, text_file: Upload, pattern: str) -> str:
166166
text = text_file.read().decode()
167167
return pattern if pattern in text else ""
168168

@@ -199,7 +199,7 @@ async def exception(self, message: str) -> AsyncGenerator[str, None]:
199199
raise ValueError(message)
200200

201201
# Without this yield, the method is not recognised as an async generator
202-
yield "Hi" # pragma: no cover
202+
yield "Hi"
203203

204204
@strawberry.subscription
205205
async def flavors(self) -> AsyncGenerator[Flavor, None]:

tests/websockets/test_graphql_transport_ws.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,8 @@
3030
from tests.http.clients.base import DebuggableGraphQLTransportWSHandler
3131
from tests.views.schema import MyExtension, Schema
3232

33-
from ..http.clients.base import WebSocketClient
34-
35-
try:
36-
from ..http.clients.fastapi import FastAPIHttpClient
37-
except ImportError: # pragma: no cover
38-
FastAPIHttpClient = None
39-
try:
40-
from ..http.clients.starlite import StarliteHttpClient
41-
except ImportError: # pragma: no cover
42-
StarliteHttpClient = None
43-
try:
44-
from ..http.clients.litestar import LitestarHttpClient
45-
except ImportError: # pragma: no cover
46-
LitestarHttpClient = None
47-
4833
if TYPE_CHECKING:
49-
from ..http.clients.base import HttpClient
34+
from ..http.clients.base import HttpClient, WebSocketClient
5035

5136

5237
@pytest_asyncio.fixture
@@ -913,6 +898,9 @@ async def test_error_handler_for_timeout(http_client: HttpClient):
913898
if isinstance(http_client, ChannelsHttpClient):
914899
pytest.skip("Can't patch on_init for this client")
915900

901+
if not AsyncMock:
902+
pytest.skip("Don't have AsyncMock")
903+
916904
ws = ws_raw
917905
handler = None
918906
errorhandler = AsyncMock()

0 commit comments

Comments
 (0)