Import testing endpoint from graphene settings

This commit is contained in:
Syberen 2021-01-24 08:24:50 +01:00
parent 5dea6ffa41
commit 2bb198db5c
3 changed files with 17 additions and 4 deletions

View File

@ -45,6 +45,7 @@ DEFAULTS = {
# https://github.com/graphql/graphiql/tree/main/packages/graphiql#options
"GRAPHIQL_HEADER_EDITOR_ENABLED": True,
"ATOMIC_MUTATIONS": False,
"TESTING_ENDPOINT": "/graphql"
}
if settings.DEBUG:

View File

@ -3,7 +3,7 @@ import warnings
from django.test import Client, TestCase
DEFAULT_GRAPHQL_URL = "/graphql/"
from graphene_django.settings import graphene_settings
def graphql_query(
@ -38,7 +38,7 @@ def graphql_query(
if client is None:
client = Client()
if not graphql_url:
graphql_url = DEFAULT_GRAPHQL_URL
graphql_url = graphene_settings.TESTING_ENDPOINT
body = {"query": query}
if operation_name:
@ -67,7 +67,7 @@ class GraphQLTestCase(TestCase):
"""
# URL to graphql endpoint
GRAPHQL_URL = DEFAULT_GRAPHQL_URL
GRAPHQL_URL = graphene_settings.TESTING_ENDPOINT
def query(
self, query, operation_name=None, input_data=None, variables=None, headers=None

View File

@ -2,9 +2,9 @@ import pytest
from .. import GraphQLTestCase
from ...tests.test_types import with_local_registry
from ...settings import graphene_settings
from django.test import Client
@with_local_registry
def test_graphql_test_case_deprecated_client_getter():
"""
@ -43,3 +43,15 @@ def test_graphql_test_case_deprecated_client_setter():
with pytest.warns(PendingDeprecationWarning):
tc._client = Client()
def test_graphql_test_case_imports_endpoint():
"""
GraphQLTestCase class should import the default endpoint from settings file
"""
assert GraphQLTestCase.GRAPHQL_URL == graphene_settings.TESTING_ENDPOINT