Skip to content

Commit aac23bc

Browse files
committed
Fix deprecation warnings
DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content.
1 parent 271b447 commit aac23bc

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

tests/sanic/test_graphqlview.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_allows_mutation_to_exist_within_a_get(app):
166166
def test_allows_post_with_json_encoding(app):
167167
_, response = app.test_client.post(
168168
uri=url_string(),
169-
data=json_dump_kwarg(query="{test}"),
169+
content=json_dump_kwarg(query="{test}"),
170170
headers={"content-type": "application/json"},
171171
)
172172

@@ -178,7 +178,7 @@ def test_allows_post_with_json_encoding(app):
178178
def test_allows_sending_a_mutation_via_post(app):
179179
_, response = app.test_client.post(
180180
uri=url_string(),
181-
data=json_dump_kwarg(query="mutation TestMutation { writeTest { test } }"),
181+
content=json_dump_kwarg(query="mutation TestMutation { writeTest { test } }"),
182182
headers={"content-type": "application/json"},
183183
)
184184

@@ -194,7 +194,7 @@ def test_allows_post_with_url_encoding(app):
194194
payload = "query={test}"
195195
_, response = app.test_client.post(
196196
uri=url_string(),
197-
data=payload,
197+
content=payload,
198198
headers={"content-type": "application/x-www-form-urlencoded"},
199199
)
200200

@@ -206,7 +206,7 @@ def test_allows_post_with_url_encoding(app):
206206
def test_supports_post_json_query_with_string_variables(app):
207207
_, response = app.test_client.post(
208208
uri=url_string(),
209-
data=json_dump_kwarg(
209+
content=json_dump_kwarg(
210210
query="query helloWho($who: String){ test(who: $who) }",
211211
variables=json.dumps({"who": "Dolly"}),
212212
),
@@ -221,7 +221,7 @@ def test_supports_post_json_query_with_string_variables(app):
221221
def test_supports_post_json_query_with_json_variables(app):
222222
_, response = app.test_client.post(
223223
uri=url_string(),
224-
data=json_dump_kwarg(
224+
content=json_dump_kwarg(
225225
query="query helloWho($who: String){ test(who: $who) }",
226226
variables={"who": "Dolly"},
227227
),
@@ -236,7 +236,7 @@ def test_supports_post_json_query_with_json_variables(app):
236236
def test_supports_post_url_encoded_query_with_string_variables(app):
237237
_, response = app.test_client.post(
238238
uri=url_string(),
239-
data=urlencode(
239+
content=urlencode(
240240
dict(
241241
query="query helloWho($who: String){ test(who: $who) }",
242242
variables=json.dumps({"who": "Dolly"}),
@@ -253,7 +253,7 @@ def test_supports_post_url_encoded_query_with_string_variables(app):
253253
def test_supports_post_json_query_with_get_variable_values(app):
254254
_, response = app.test_client.post(
255255
uri=url_string(variables=json.dumps({"who": "Dolly"})),
256-
data=json_dump_kwarg(
256+
content=json_dump_kwarg(
257257
query="query helloWho($who: String){ test(who: $who) }",
258258
),
259259
headers={"content-type": "application/json"},
@@ -267,7 +267,7 @@ def test_supports_post_json_query_with_get_variable_values(app):
267267
def test_post_url_encoded_query_with_get_variable_values(app):
268268
_, response = app.test_client.post(
269269
uri=url_string(variables=json.dumps({"who": "Dolly"})),
270-
data=urlencode(
270+
content=urlencode(
271271
dict(
272272
query="query helloWho($who: String){ test(who: $who) }",
273273
)
@@ -283,7 +283,7 @@ def test_post_url_encoded_query_with_get_variable_values(app):
283283
def test_supports_post_raw_text_query_with_get_variable_values(app):
284284
_, response = app.test_client.post(
285285
uri=url_string(variables=json.dumps({"who": "Dolly"})),
286-
data="query helloWho($who: String){ test(who: $who) }",
286+
content="query helloWho($who: String){ test(who: $who) }",
287287
headers={"content-type": "application/graphql"},
288288
)
289289

@@ -295,7 +295,7 @@ def test_supports_post_raw_text_query_with_get_variable_values(app):
295295
def test_allows_post_with_operation_name(app):
296296
_, response = app.test_client.post(
297297
uri=url_string(),
298-
data=json_dump_kwarg(
298+
content=json_dump_kwarg(
299299
query="""
300300
query helloYou { test(who: "You"), ...shared }
301301
query helloWorld { test(who: "World"), ...shared }
@@ -319,7 +319,7 @@ def test_allows_post_with_operation_name(app):
319319
def test_allows_post_with_get_operation_name(app):
320320
_, response = app.test_client.post(
321321
uri=url_string(operationName="helloWorld"),
322-
data="""
322+
content="""
323323
query helloYou { test(who: "You"), ...shared }
324324
query helloWorld { test(who: "World"), ...shared }
325325
query helloDolly { test(who: "Dolly"), ...shared }
@@ -404,7 +404,7 @@ def test_handles_errors_caused_by_a_lack_of_query(app):
404404
@pytest.mark.parametrize("app", [create_app()])
405405
def test_handles_batch_correctly_if_is_disabled(app):
406406
_, response = app.test_client.post(
407-
uri=url_string(), data="[]", headers={"content-type": "application/json"}
407+
uri=url_string(), content="[]", headers={"content-type": "application/json"}
408408
)
409409

410410
assert response.status == 400
@@ -420,7 +420,9 @@ def test_handles_batch_correctly_if_is_disabled(app):
420420
@pytest.mark.parametrize("app", [create_app()])
421421
def test_handles_incomplete_json_bodies(app):
422422
_, response = app.test_client.post(
423-
uri=url_string(), data='{"query":', headers={"content-type": "application/json"}
423+
uri=url_string(),
424+
content='{"query":',
425+
headers={"content-type": "application/json"},
424426
)
425427

426428
assert response.status == 400
@@ -433,7 +435,7 @@ def test_handles_incomplete_json_bodies(app):
433435
def test_handles_plain_post_text(app):
434436
_, response = app.test_client.post(
435437
uri=url_string(variables=json.dumps({"who": "Dolly"})),
436-
data="query helloWho($who: String){ test(who: $who) }",
438+
content="query helloWho($who: String){ test(who: $who) }",
437439
headers={"content-type": "text/plain"},
438440
)
439441
assert response.status == 400
@@ -530,7 +532,7 @@ def test_post_multipart_data(app):
530532

531533
_, response = app.test_client.post(
532534
uri=url_string(),
533-
data=data,
535+
content=data,
534536
headers={"content-type": "multipart/form-data; boundary=----sanicgraphql"},
535537
)
536538

@@ -542,7 +544,7 @@ def test_post_multipart_data(app):
542544
def test_batch_allows_post_with_json_encoding(app):
543545
_, response = app.test_client.post(
544546
uri=url_string(),
545-
data=json_dump_kwarg_list(id=1, query="{test}"),
547+
content=json_dump_kwarg_list(id=1, query="{test}"),
546548
headers={"content-type": "application/json"},
547549
)
548550

@@ -554,7 +556,7 @@ def test_batch_allows_post_with_json_encoding(app):
554556
def test_batch_supports_post_json_query_with_json_variables(app):
555557
_, response = app.test_client.post(
556558
uri=url_string(),
557-
data=json_dump_kwarg_list(
559+
content=json_dump_kwarg_list(
558560
id=1,
559561
query="query helloWho($who: String){ test(who: $who) }",
560562
variables={"who": "Dolly"},
@@ -570,7 +572,7 @@ def test_batch_supports_post_json_query_with_json_variables(app):
570572
def test_batch_allows_post_with_operation_name(app):
571573
_, response = app.test_client.post(
572574
uri=url_string(),
573-
data=json_dump_kwarg_list(
575+
content=json_dump_kwarg_list(
574576
id=1,
575577
query="""
576578
query helloYou { test(who: "You"), ...shared }

0 commit comments

Comments
 (0)