mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 09:42:32 +03:00
Run black
This commit is contained in:
parent
0afd512bb2
commit
e2ca1ed5e0
|
@ -52,7 +52,9 @@ def get_choices(choices):
|
|||
yield name, value, description
|
||||
|
||||
|
||||
def convert_django_field_with_choices(field, registry=None, convert_choices_to_enum=True):
|
||||
def convert_django_field_with_choices(
|
||||
field, registry=None, convert_choices_to_enum=True
|
||||
):
|
||||
if registry is not None:
|
||||
converted = registry.get_converted_field(field)
|
||||
if converted:
|
||||
|
|
|
@ -208,8 +208,7 @@ def test_field_with_choices_convert_enum_false():
|
|||
app_label = "test"
|
||||
|
||||
graphene_type = convert_django_field_with_choices(
|
||||
field,
|
||||
convert_choices_to_enum=False
|
||||
field, convert_choices_to_enum=False
|
||||
)
|
||||
assert isinstance(graphene_type, graphene.String)
|
||||
|
||||
|
|
|
@ -230,13 +230,15 @@ def test_django_objecttype_exclude_fields():
|
|||
assert "email" not in fields
|
||||
|
||||
|
||||
class TestDjangoObjectType():
|
||||
class TestDjangoObjectType:
|
||||
@pytest.fixture
|
||||
def PetModel(self):
|
||||
class PetModel(models.Model):
|
||||
kind = models.CharField(choices=(('cat', 'Cat'), ('dog', 'Dog')))
|
||||
cuteness = models.IntegerField(choices=(
|
||||
(1, 'Kind of cute'), (2, 'Pretty cute'), (3, 'OMG SO CUTE!!!')))
|
||||
kind = models.CharField(choices=(("cat", "Cat"), ("dog", "Dog")))
|
||||
cuteness = models.IntegerField(
|
||||
choices=((1, "Kind of cute"), (2, "Pretty cute"), (3, "OMG SO CUTE!!!"))
|
||||
)
|
||||
|
||||
return PetModel
|
||||
|
||||
def test_django_objecttype_convert_choices_enum_false(self, PetModel):
|
||||
|
@ -250,7 +252,8 @@ class TestDjangoObjectType():
|
|||
|
||||
schema = Schema(query=Query)
|
||||
|
||||
assert str(schema) == dedent("""\
|
||||
assert str(schema) == dedent(
|
||||
"""\
|
||||
schema {
|
||||
query: Query
|
||||
}
|
||||
|
@ -264,20 +267,22 @@ class TestDjangoObjectType():
|
|||
type Query {
|
||||
pet: Pet
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
def test_django_objecttype_convert_choices_enum_list(self, PetModel):
|
||||
class Pet(DjangoObjectType):
|
||||
class Meta:
|
||||
model = PetModel
|
||||
convert_choices_to_enum = ['kind']
|
||||
convert_choices_to_enum = ["kind"]
|
||||
|
||||
class Query(ObjectType):
|
||||
pet = Field(Pet)
|
||||
|
||||
schema = Schema(query=Query)
|
||||
|
||||
assert str(schema) == dedent("""\
|
||||
assert str(schema) == dedent(
|
||||
"""\
|
||||
schema {
|
||||
query: Query
|
||||
}
|
||||
|
@ -296,4 +301,5 @@ class TestDjangoObjectType():
|
|||
type Query {
|
||||
pet: Pet
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
|
|
@ -18,8 +18,9 @@ if six.PY3:
|
|||
from typing import Type
|
||||
|
||||
|
||||
def construct_fields(model, registry, only_fields, exclude_fields,
|
||||
convert_choices_to_enum):
|
||||
def construct_fields(
|
||||
model, registry, only_fields, exclude_fields, convert_choices_to_enum
|
||||
):
|
||||
_model_fields = get_model_fields(model)
|
||||
|
||||
fields = OrderedDict()
|
||||
|
@ -44,7 +45,8 @@ def construct_fields(model, registry, only_fields, exclude_fields,
|
|||
_convert_choices_to_enum = False
|
||||
|
||||
converted = convert_django_field_with_choices(
|
||||
field, registry, convert_choices_to_enum=_convert_choices_to_enum)
|
||||
field, registry, convert_choices_to_enum=_convert_choices_to_enum
|
||||
)
|
||||
fields[name] = converted
|
||||
|
||||
return fields
|
||||
|
@ -103,13 +105,9 @@ class DjangoObjectType(ObjectType):
|
|||
|
||||
django_fields = yank_fields_from_attrs(
|
||||
construct_fields(
|
||||
model,
|
||||
registry,
|
||||
only_fields,
|
||||
exclude_fields,
|
||||
convert_choices_to_enum
|
||||
model, registry, only_fields, exclude_fields, convert_choices_to_enum
|
||||
),
|
||||
_as=Field
|
||||
_as=Field,
|
||||
)
|
||||
|
||||
if use_connection is None and interfaces:
|
||||
|
|
Loading…
Reference in New Issue
Block a user