Doc clarification for headers arg in testing utils (#1117)

I think it might be helpful to add an explicit hint that HTTP headers should be prepended with `HTTP_` as required by `django.test.Client` (at least it was not super obvious to me when I tried to use it).
This commit is contained in:
Jiahao Li 2021-02-22 23:13:49 -05:00 committed by GitHub
parent 52880166bd
commit beb2e4aae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,7 +28,9 @@ def graphql_query(
variables (dict) - If provided, the "variables" field in GraphQL will be variables (dict) - If provided, the "variables" field in GraphQL will be
set to this value. set to this value.
headers (dict) - If provided, the headers in POST request to GRAPHQL_URL headers (dict) - If provided, the headers in POST request to GRAPHQL_URL
will be set to this value. will be set to this value. Keys should be prepended with
"HTTP_" (e.g. to specify the "Authorization" HTTP header,
use "HTTP_AUTHORIZATION" as the key).
client (django.test.Client) - Test client. Defaults to django.test.Client. client (django.test.Client) - Test client. Defaults to django.test.Client.
graphql_url (string) - URL to graphql endpoint. Defaults to "/graphql". graphql_url (string) - URL to graphql endpoint. Defaults to "/graphql".
@ -85,7 +87,9 @@ class GraphQLTestCase(TestCase):
variables (dict) - If provided, the "variables" field in GraphQL will be variables (dict) - If provided, the "variables" field in GraphQL will be
set to this value. set to this value.
headers (dict) - If provided, the headers in POST request to GRAPHQL_URL headers (dict) - If provided, the headers in POST request to GRAPHQL_URL
will be set to this value. will be set to this value. Keys should be prepended with
"HTTP_" (e.g. to specify the "Authorization" HTTP header,
use "HTTP_AUTHORIZATION" as the key).
Returns: Returns:
Response object from client Response object from client