From 448802b2b6a317880456ab95b5fd19227d958cbb Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Fri, 14 Jun 2019 15:07:32 +0100 Subject: [PATCH] Add test and documentation note That setting to an empty list is the same as setting the value as False --- docs/queries.rst | 3 +++ graphene_django/tests/test_types.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/queries.rst b/docs/queries.rst index 75bee3d..fe67a9d 100644 --- a/docs/queries.rst +++ b/docs/queries.rst @@ -153,6 +153,9 @@ automatically converted into enums: model = PetModel convert_choices_to_enum = ['kind'] +**Note:** Setting ``convert_choices_to_enum`` to an empty list is the same as +setting it to `False`. + Related models -------------- diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index f7c26a9..f7e41bf 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -303,3 +303,32 @@ class TestDjangoObjectType: } """ ) + + def test_django_objecttype_convert_choices_enum_empty_list(self, PetModel): + class Pet(DjangoObjectType): + class Meta: + model = PetModel + convert_choices_to_enum = [] + + class Query(ObjectType): + pet = Field(Pet) + + schema = Schema(query=Query) + + assert str(schema) == dedent( + """\ + schema { + query: Query + } + + type Pet { + id: ID! + kind: String! + cuteness: Int! + } + + type Query { + pet: Pet + } + """ + )