mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-13 17:52:19 +03:00
install requires for backwards compatible enum
This commit is contained in:
parent
c827267cb9
commit
bc06637278
|
@ -114,8 +114,5 @@ class MyCustomChoices(DjangoChoicesEnum):
|
|||
|
||||
class FilmWithChoices(models.Model):
|
||||
genre = models.CharField(
|
||||
max_length=2,
|
||||
help_text="Genre",
|
||||
choices=MyCustomChoices.choices(),
|
||||
default=MyCustomChoices.choices()[0][0],
|
||||
max_length=2, help_text="Genre", choices=MyCustomChoices.choices(), default="DO"
|
||||
)
|
||||
|
|
|
@ -1072,7 +1072,7 @@ def test_using_django_choices_enum():
|
|||
def resolve_films(self, info, **args):
|
||||
return Film.objects.all()
|
||||
|
||||
f = FilmWithChoices.objects.create()
|
||||
f = FilmWithChoices.objects.create(genre="DO")
|
||||
|
||||
query = """
|
||||
query NodeFilteringQuery {
|
||||
|
@ -1104,7 +1104,8 @@ def test_using_django_choices_enum():
|
|||
result = schema.execute(query)
|
||||
assert not result.errors
|
||||
enum_values = result.data["__type"]["enumValues"]
|
||||
assert enum_values == [
|
||||
{"name": "DO", "description": "Documentary"},
|
||||
for result in [
|
||||
{"name": "OT", "description": "Other"},
|
||||
]
|
||||
{"name": "DO", "description": "Documentary"},
|
||||
]:
|
||||
assert result in enum_values
|
||||
|
|
|
@ -242,4 +242,6 @@ def test_custom_django_choices_enum():
|
|||
assert graphene_enum._meta.description(graphene_enum.FOO) == "foo"
|
||||
|
||||
# As a Django choices option
|
||||
assert MyChoicesEnum.choices() == [("FOO", "foo"), ("BAR", "bar")]
|
||||
resulting_choices = MyChoicesEnum.choices()
|
||||
for result in (("FOO", "foo"), ("BAR", "bar")):
|
||||
assert result in resulting_choices
|
||||
|
|
|
@ -180,7 +180,7 @@ class DjangoChoicesEnum(object):
|
|||
class Model(models.model)
|
||||
some_field = CharField(choices=ChoicesType.choices())
|
||||
"""
|
||||
return [(k, v) for k, v in cls.__dict__.items() if not k.startswith("__")]
|
||||
return tuple((k, v) for k, v in cls.__dict__.items() if not k.startswith("__"))
|
||||
|
||||
@classmethod
|
||||
def as_enum(cls):
|
||||
|
|
Loading…
Reference in New Issue
Block a user