Rename settings field

This commit is contained in:
Jonathan Kim 2020-01-22 10:02:59 +00:00
parent 8c20e183ad
commit fdaa0bf2ba
4 changed files with 7 additions and 7 deletions

View File

@ -70,7 +70,7 @@ def convert_choices_to_named_enum_with_descriptions(name, choices):
def generate_enum_name(django_model_meta, field):
if graphene_settings.CHOICES_TO_ENUM_UNIQUE_TYPE_NAME is True:
if graphene_settings.CHOICES_TO_ENUM_V3_NAMING is True:
name = "DjangoModel{app_label}{object_name}{field_name}Choices".format(
app_label=to_camel_case(django_model_meta.app_label.title()),
object_name=django_model_meta.object_name,

View File

@ -36,8 +36,8 @@ DEFAULTS = {
# Max items returned in ConnectionFields / FilterConnectionFields
"RELAY_CONNECTION_MAX_LIMIT": 100,
"CAMELCASE_ERRORS": False,
# Set to True to enable unique naming for choice field Enum's
"CHOICES_TO_ENUM_UNIQUE_TYPE_NAME": False,
# Set to True to enable v3 naming convention for choice field Enum's
"CHOICES_TO_ENUM_V3_NAMING": False,
}
if settings.DEBUG:

View File

@ -335,7 +335,7 @@ def test_should_postgres_range_convert_list():
def test_generate_enum_name():
MockDjangoModelMeta = namedtuple("DjangoMeta", ["app_label", "object_name"])
graphene_settings.CHOICES_TO_ENUM_UNIQUE_TYPE_NAME = True
graphene_settings.CHOICES_TO_ENUM_V3_NAMING = True
# Simple case
field = graphene.Field(graphene.String, name="type")
@ -352,4 +352,4 @@ def test_generate_enum_name():
== "DjangoModelSomeLongAppNameSomeObjectFizzBuzzChoices"
)
graphene_settings.CHOICES_TO_ENUM_UNIQUE_TYPE_NAME = False
graphene_settings.CHOICES_TO_ENUM_V3_NAMING = False

View File

@ -496,7 +496,7 @@ class TestDjangoObjectType:
)
def test_django_objecttype_convert_choices_enum_naming_collisions(self, PetModel):
graphene_settings.CHOICES_TO_ENUM_UNIQUE_TYPE_NAME = True
graphene_settings.CHOICES_TO_ENUM_V3_NAMING = True
class PetModelKind(DjangoObjectType):
class Meta:
@ -529,7 +529,7 @@ class TestDjangoObjectType:
}
"""
)
graphene_settings.CHOICES_TO_ENUM_UNIQUE_TYPE_NAME = False
graphene_settings.CHOICES_TO_ENUM_V3_NAMING = False
def test_django_objecttype_choices_override_enum(self, PetModel):
def convert_choice(model, field_name, **kwargs):