Skip to content

Commit db9c296

Browse files
committed
Fix tests for sanic v22.6
1 parent 226d4c7 commit db9c296

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

graphql_server/sanic/graphqlview.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_validation_rules(self):
8585
return specified_rules
8686
return self.validation_rules
8787

88-
async def dispatch_request(self, request, *args, **kwargs):
88+
async def __handle_request(self, request, *args, **kwargs):
8989
try:
9090
request_method = request.method.lower()
9191
data = self.parse_body(request)
@@ -173,6 +173,8 @@ async def dispatch_request(self, request, *args, **kwargs):
173173
content_type="application/json",
174174
)
175175

176+
get = post = put = head = options = patch = delete = __handle_request
177+
176178
# noinspection PyBroadException
177179
def parse_body(self, request):
178180
content_type = self.get_mime_type(request)

tests/sanic/test_graphqlview.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ def test_handles_poorly_formed_variables(app):
459459
def test_handles_unsupported_http_methods(app):
460460
_, response = app.test_client.put(uri=url_string(query="{test}"))
461461
assert response.status == 405
462-
assert response.headers["Allow"] in ["GET, POST", "HEAD, GET, POST, OPTIONS"]
462+
allowed_methods = set(
463+
method.strip() for method in response.headers["Allow"].split(",")
464+
)
465+
assert allowed_methods in [{"GET", "POST"}, {"HEAD", "GET", "POST", "OPTIONS"}]
463466
assert response_json(response) == {
464467
"errors": [
465468
{

0 commit comments

Comments
 (0)