mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-05 04:43:29 +03:00
format and lint
This commit is contained in:
parent
264b84aed8
commit
6ae636230c
|
@ -90,11 +90,13 @@ class CNNReporter(Reporter):
|
||||||
|
|
||||||
objects = CNNReporterManager()
|
objects = CNNReporterManager()
|
||||||
|
|
||||||
|
|
||||||
class APNewsReporter(Reporter):
|
class APNewsReporter(Reporter):
|
||||||
"""
|
"""
|
||||||
This class only inherits from Reporter for testing multi table inheritence
|
This class only inherits from Reporter for testing multi table inheritence
|
||||||
similar to what you'd see in django-polymorphic
|
similar to what you'd see in django-polymorphic
|
||||||
"""
|
"""
|
||||||
|
|
||||||
alias = models.CharField(max_length=30)
|
alias = models.CharField(max_length=30)
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,16 @@ from ..compat import IntegerRangeField, MissingType
|
||||||
from ..fields import DjangoConnectionField
|
from ..fields import DjangoConnectionField
|
||||||
from ..types import DjangoObjectType
|
from ..types import DjangoObjectType
|
||||||
from ..utils import DJANGO_FILTER_INSTALLED
|
from ..utils import DJANGO_FILTER_INSTALLED
|
||||||
from .models import Article, CNNReporter, Film, FilmDetails, Person, Pet, Reporter, APNewsReporter
|
from .models import (
|
||||||
|
Article,
|
||||||
|
CNNReporter,
|
||||||
|
Film,
|
||||||
|
FilmDetails,
|
||||||
|
Person,
|
||||||
|
Pet,
|
||||||
|
Reporter,
|
||||||
|
APNewsReporter,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_should_query_only_fields():
|
def test_should_query_only_fields():
|
||||||
|
@ -1076,7 +1085,7 @@ def test_model_inheritance_support_reverse_relationships():
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Film
|
model = Film
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
class ReporterType(DjangoObjectType):
|
class ReporterType(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Reporter
|
model = Reporter
|
||||||
|
@ -1090,7 +1099,7 @@ def test_model_inheritance_support_reverse_relationships():
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
use_connection = True
|
use_connection = True
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
class APNewsReporterType(DjangoObjectType):
|
class APNewsReporterType(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = APNewsReporter
|
model = APNewsReporter
|
||||||
|
@ -1213,7 +1222,7 @@ def test_model_inheritance_support_local_relationships():
|
||||||
"""
|
"""
|
||||||
This test asserts that we can query local relationships for all Reporters and proxied Reporters and multi table Reporters.
|
This test asserts that we can query local relationships for all Reporters and proxied Reporters and multi table Reporters.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class PersonType(DjangoObjectType):
|
class PersonType(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Person
|
model = Person
|
||||||
|
@ -1232,7 +1241,7 @@ def test_model_inheritance_support_local_relationships():
|
||||||
interfaces = (Node,)
|
interfaces = (Node,)
|
||||||
use_connection = True
|
use_connection = True
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
class APNewsReporterType(DjangoObjectType):
|
class APNewsReporterType(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = APNewsReporter
|
model = APNewsReporter
|
||||||
|
@ -1246,10 +1255,7 @@ def test_model_inheritance_support_local_relationships():
|
||||||
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reporter_fan = Person.objects.create(name="Reporter Fan")
|
||||||
reporter_fan = Person.objects.create(
|
|
||||||
name="Reporter Fan"
|
|
||||||
)
|
|
||||||
|
|
||||||
reporter.fans.add(reporter_fan)
|
reporter.fans.add(reporter_fan)
|
||||||
reporter.save()
|
reporter.save()
|
||||||
|
@ -1261,18 +1267,14 @@ def test_model_inheritance_support_local_relationships():
|
||||||
a_choice=1,
|
a_choice=1,
|
||||||
reporter_type=2, # set this guy to be CNN
|
reporter_type=2, # set this guy to be CNN
|
||||||
)
|
)
|
||||||
cnn_fan = Person.objects.create(
|
cnn_fan = Person.objects.create(name="CNN Fan")
|
||||||
name="CNN Fan"
|
|
||||||
)
|
|
||||||
cnn_reporter.fans.add(cnn_fan)
|
cnn_reporter.fans.add(cnn_fan)
|
||||||
cnn_reporter.save()
|
cnn_reporter.save()
|
||||||
|
|
||||||
ap_news_reporter = APNewsReporter.objects.create(
|
ap_news_reporter = APNewsReporter.objects.create(
|
||||||
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
||||||
)
|
)
|
||||||
ap_news_fan = Person.objects.create(
|
ap_news_fan = Person.objects.create(name="AP News Fan")
|
||||||
name="AP News Fan"
|
|
||||||
)
|
|
||||||
ap_news_reporter.fans.add(ap_news_fan)
|
ap_news_reporter.fans.add(ap_news_fan)
|
||||||
ap_news_reporter.save()
|
ap_news_reporter.save()
|
||||||
|
|
||||||
|
@ -1368,6 +1370,7 @@ def test_model_inheritance_support_local_relationships():
|
||||||
result = schema.execute(query)
|
result = schema.execute(query)
|
||||||
assert result.data == expected
|
assert result.data == expected
|
||||||
|
|
||||||
|
|
||||||
def test_should_resolve_get_queryset_connectionfields():
|
def test_should_resolve_get_queryset_connectionfields():
|
||||||
reporter_1 = Reporter.objects.create(
|
reporter_1 = Reporter.objects.create(
|
||||||
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
first_name="John", last_name="Doe", email="johndoe@example.com", a_choice=1
|
||||||
|
|
|
@ -24,7 +24,11 @@ def test_get_reverse_fields_includes_proxied_models():
|
||||||
cnn_reporter_fields = get_reverse_fields(CNNReporter, [])
|
cnn_reporter_fields = get_reverse_fields(CNNReporter, [])
|
||||||
ap_news_reporter_fields = get_reverse_fields(APNewsReporter, [])
|
ap_news_reporter_fields = get_reverse_fields(APNewsReporter, [])
|
||||||
|
|
||||||
assert len(list(reporter_fields)) == len(list(cnn_reporter_fields)) == len(list(ap_news_reporter_fields))
|
assert (
|
||||||
|
len(list(reporter_fields))
|
||||||
|
== len(list(cnn_reporter_fields))
|
||||||
|
== len(list(ap_news_reporter_fields))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_camelize():
|
def test_camelize():
|
||||||
|
|
|
@ -81,7 +81,7 @@ def get_local_fields(model):
|
||||||
):
|
):
|
||||||
if field.name not in local_fields_dict:
|
if field.name not in local_fields_dict:
|
||||||
local_fields_dict[field.name] = field
|
local_fields_dict[field.name] = field
|
||||||
|
|
||||||
return list(local_fields_dict.items())
|
return list(local_fields_dict.items())
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user