|
2 | 2 | from django.test import TestCase
|
3 | 3 | from py.test import raises
|
4 | 4 |
|
5 |
| -from graphene_django.tests.models import Pet, Film, FilmDetails |
| 5 | +from graphene_django.tests.models import Film, FilmDetails, Pet |
| 6 | + |
| 7 | +from ...settings import graphene_settings |
6 | 8 | from ..mutation import DjangoFormMutation, DjangoModelFormMutation
|
7 | 9 |
|
8 | 10 |
|
@@ -41,6 +43,22 @@ class Meta:
|
41 | 43 | assert "text" in MyMutation.Input._meta.fields
|
42 | 44 |
|
43 | 45 |
|
| 46 | +def test_mutation_error_camelcased(): |
| 47 | + class ExtraPetForm(PetForm): |
| 48 | + test_field = forms.CharField(required=True) |
| 49 | + |
| 50 | + class PetMutation(DjangoModelFormMutation): |
| 51 | + class Meta: |
| 52 | + form_class = ExtraPetForm |
| 53 | + |
| 54 | + result = PetMutation.mutate_and_get_payload(None, None) |
| 55 | + assert {f.field for f in result.errors} == {"name", "age", "test_field"} |
| 56 | + graphene_settings.DJANGO_GRAPHENE_CAMELCASE_ERRORS = True |
| 57 | + result = PetMutation.mutate_and_get_payload(None, None) |
| 58 | + assert {f.field for f in result.errors} == {"name", "age", "testField"} |
| 59 | + graphene_settings.DJANGO_GRAPHENE_CAMELCASE_ERRORS = False |
| 60 | + |
| 61 | + |
44 | 62 | class ModelFormMutationTests(TestCase):
|
45 | 63 | def test_default_meta_fields(self):
|
46 | 64 | class PetMutation(DjangoModelFormMutation):
|
|
0 commit comments