mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-04 12:23:13 +03:00
ran black
This commit is contained in:
parent
cbaeccf65e
commit
2b01eb1500
|
@ -2,17 +2,17 @@ import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.insert(0, ROOT_PATH + '/examples/')
|
sys.path.insert(0, ROOT_PATH + "/examples/")
|
||||||
|
|
||||||
SECRET_KEY = 1
|
SECRET_KEY = 1
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
'graphene_django',
|
"graphene_django",
|
||||||
'graphene_django.rest_framework',
|
"graphene_django.rest_framework",
|
||||||
'graphene_django.tests',
|
"graphene_django.tests",
|
||||||
'starwars',
|
"starwars",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -21,22 +21,17 @@ MIDDLEWARE = [
|
||||||
]
|
]
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "django_test.sqlite",}
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': 'django_test.sqlite',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
'DIRS': [],
|
"DIRS": [],
|
||||||
'APP_DIRS': True,
|
"APP_DIRS": True,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
GRAPHENE = {
|
GRAPHENE = {"SCHEMA": "graphene_django.tests.schema_view.schema"}
|
||||||
'SCHEMA': 'graphene_django.tests.schema_view.schema'
|
|
||||||
}
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'graphene_django.tests.urls'
|
ROOT_URLCONF = "graphene_django.tests.urls"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# -- also in settings.py INSTALLED_APPS
|
# -- also in settings.py INSTALLED_APPS
|
||||||
import json
|
import json
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -39,12 +40,7 @@ def test_graphiql_is_enabled(client):
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_qfactor_graphiql(client):
|
def test_qfactor_graphiql(client):
|
||||||
response = client.get(
|
response = client.get(url_string(query="{test}", HTTP_ACCEPT="text/html",))
|
||||||
url_string(
|
|
||||||
query="{test}",
|
|
||||||
HTTP_ACCEPT="text/html",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
##assert response["Content-Type"].split(";")[0] == "text/html"
|
##assert response["Content-Type"].split(";")[0] == "text/html"
|
||||||
|
@ -53,10 +49,7 @@ def test_qfactor_graphiql(client):
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_qfactor_json(client):
|
def test_qfactor_json(client):
|
||||||
response = client.get(
|
response = client.get(
|
||||||
url_string(
|
url_string(query="{test}", HTTP_ACCEPT="application/json",)
|
||||||
query="{test}",
|
|
||||||
HTTP_ACCEPT="application/json",
|
|
||||||
)
|
|
||||||
).json()
|
).json()
|
||||||
|
|
||||||
# returns just json as __dict__
|
# returns just json as __dict__
|
||||||
|
@ -237,7 +230,7 @@ def test_batch_allows_post_with_json_encoding(client):
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# returns just json as __dict__
|
# returns just json as __dict__
|
||||||
expected_dict = [{"id": 1, "data": {"test": "Hello World"}, 'status': 200}]
|
expected_dict = [{"id": 1, "data": {"test": "Hello World"}, "status": 200}]
|
||||||
# directly compare all key,value for __dict__ -- NOTE responce is list of stuff!
|
# directly compare all key,value for __dict__ -- NOTE responce is list of stuff!
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -268,7 +261,7 @@ def test_allows_sending_a_mutation_via_post(client):
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
'''
|
"""
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_allows_post_with_url_encoding(client):
|
def test_allows_post_with_url_encoding(client):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
@ -282,7 +275,7 @@ def test_allows_post_with_url_encoding(client):
|
||||||
expected_dict = {"data": {"test": "Hello World"}}
|
expected_dict = {"data": {"test": "Hello World"}}
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -317,7 +310,7 @@ def test_batch_supports_post_json_query_with_string_variables(client):
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# returns just json as __dict__
|
# returns just json as __dict__
|
||||||
expected_dict = [{"id": 1, "data": {"test": "Hello Dolly"}, 'status': 200}]
|
expected_dict = [{"id": 1, "data": {"test": "Hello Dolly"}, "status": 200}]
|
||||||
# directly compare all key,value for __dict__ -- NOTE responce is list of stuff!
|
# directly compare all key,value for __dict__ -- NOTE responce is list of stuff!
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -354,14 +347,12 @@ def test_batch_supports_post_json_query_with_json_variables(client):
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
# returns just json as __dict__
|
# returns just json as __dict__
|
||||||
expected_dict = [
|
expected_dict = [{"id": 1, "data": {"test": "Hello Dolly"}, "status": 200}]
|
||||||
{"id": 1, "data": {"test": "Hello Dolly"}, "status": 200}
|
|
||||||
]
|
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
'''
|
"""
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_supports_post_url_encoded_query_with_string_variables(client):
|
def test_supports_post_url_encoded_query_with_string_variables(client):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
@ -380,7 +371,7 @@ def test_supports_post_url_encoded_query_with_string_variables(client):
|
||||||
expected_dict = {"data": {"test": "Hello Dolly"}}
|
expected_dict = {"data": {"test": "Hello Dolly"}}
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -398,7 +389,7 @@ def test_supports_post_json_quey_with_get_variable_values(client):
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
'''
|
"""
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_post_url_encoded_query_with_get_variable_values(client):
|
def test_post_url_encoded_query_with_get_variable_values(client):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
@ -412,10 +403,10 @@ def test_post_url_encoded_query_with_get_variable_values(client):
|
||||||
expected_dict = {"data": {"test": "Hello Dolly"}}
|
expected_dict = {"data": {"test": "Hello Dolly"}}
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
'''
|
"""
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_supports_post_raw_text_query_with_get_variable_values(client):
|
def test_supports_post_raw_text_query_with_get_variable_values(client):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
@ -429,7 +420,7 @@ def test_supports_post_raw_text_query_with_get_variable_values(client):
|
||||||
expected_dict = {"data": {"test": "Hello Dolly"}}
|
expected_dict = {"data": {"test": "Hello Dolly"}}
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -519,7 +510,7 @@ def test_allows_post_with_get_operation_name(client):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
'''
|
"""
|
||||||
# inherited/ ???
|
# inherited/ ???
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@pytest.mark.urls("graphene_django.tests.urls_inherited")
|
@pytest.mark.urls("graphene_django.tests.urls_inherited")
|
||||||
|
@ -538,7 +529,7 @@ def test_inherited_class_with_attributes_works(client):
|
||||||
# Check graphiql works
|
# Check graphiql works
|
||||||
response = client.get(url_string(inherited_url), HTTP_ACCEPT="text/html")
|
response = client.get(url_string(inherited_url), HTTP_ACCEPT="text/html")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -578,16 +569,13 @@ def test_handles_syntax_errors_caught_by_graphql(client):
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_handles_errors_caused_by_a_lack_of_query(client):
|
def test_handles_errors_caused_by_a_lack_of_query(client):
|
||||||
response = client.get(url_string())
|
response = client.get(url_string())
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
# returns just json as list of __dict__
|
# returns just json as list of __dict__
|
||||||
expected_dict = {
|
expected_dict = {"errors": [{"message": "Must provide query string."}]}
|
||||||
"errors": [{"message": "Must provide query string."}]
|
|
||||||
}
|
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -605,16 +593,13 @@ def test_handles_not_expected_json_bodies(client):
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_handles_invalid_json_bodies(client):
|
def test_handles_invalid_json_bodies(client):
|
||||||
response = client.post(url_string(), "[oh}", "application/json")
|
response = client.post(url_string(), "[oh}", "application/json")
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
# returns just json as list of __dict__
|
# returns just json as list of __dict__
|
||||||
expected_dict = {
|
expected_dict = {"errors": [{"message": "POST body sent invalid JSON."}]}
|
||||||
"errors": [{"message": "POST body sent invalid JSON."}]
|
|
||||||
}
|
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -636,8 +621,7 @@ def test_handles_django_request_error(client, monkeypatch):
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
'''
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_handles_plain_post_text(client):
|
def test_handles_plain_post_text(client):
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
@ -652,7 +636,7 @@ def test_handles_plain_post_text(client):
|
||||||
}
|
}
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -664,9 +648,7 @@ def test_handles_poorly_formed_variables(client):
|
||||||
)
|
)
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
# returns just json as list of __dict__
|
# returns just json as list of __dict__
|
||||||
expected_dict = {
|
expected_dict = {"errors": [{"message": "Variables are invalid JSON."}]}
|
||||||
"errors": [{"message": "Variables are invalid JSON."}]
|
|
||||||
}
|
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -691,9 +673,7 @@ def test_handles_incomplete_json_bodies(client):
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
# returns just json as list of __dict__
|
# returns just json as list of __dict__
|
||||||
expected_dict = {
|
expected_dict = {"errors": [{"message": "POST body sent invalid JSON."}]}
|
||||||
"errors": [{"message": "POST body sent invalid JSON."}]
|
|
||||||
}
|
|
||||||
# directly compare all key,value for __dict__
|
# directly compare all key,value for __dict__
|
||||||
assert response.json() == expected_dict
|
assert response.json() == expected_dict
|
||||||
|
|
||||||
|
@ -710,7 +690,7 @@ def test_passes_request_into_context_request(client):
|
||||||
|
|
||||||
|
|
||||||
# pretty() -- since we are not comparing as string, not sure about this
|
# pretty() -- since we are not comparing as string, not sure about this
|
||||||
'''
|
"""
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@pytest.mark.urls("graphene_django.tests.urls_pretty")
|
@pytest.mark.urls("graphene_django.tests.urls_pretty")
|
||||||
def test_supports_pretty_printing(client):
|
def test_supports_pretty_printing(client):
|
||||||
|
@ -728,4 +708,4 @@ def test_supports_pretty_printing_by_request(client):
|
||||||
assert response.content.decode() == (
|
assert response.content.decode() == (
|
||||||
"{\n" ' "data": {\n' ' "test": "Hello World"\n' " }\n" "}"
|
"{\n" ' "data": {\n' ' "test": "Hello World"\n' " }\n" "}"
|
||||||
)
|
)
|
||||||
'''
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user