Skip to content

Commit 65e6302

Browse files
author
=
committed
Add tests
1 parent 24706f5 commit 65e6302

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

graphene_django/rest_framework/tests/test_mutation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ class Meta:
5252
assert 'model' in MyMutation.Input._meta.fields
5353

5454

55+
def test_exclude_fields():
56+
class MyMutation(SerializerMutation):
57+
class Meta:
58+
serializer_class = MyModelSerializer
59+
exclude_fields = ['created']
60+
61+
assert 'cool_name' in MyMutation._meta.fields
62+
assert 'created' not in MyMutation._meta.fields
63+
assert 'errors' in MyMutation._meta.fields
64+
assert 'cool_name' in MyMutation.Input._meta.fields
65+
assert 'created' not in MyMutation.Input._meta.fields
66+
67+
5568
def test_nested_model():
5669

5770
class MyFakeModelGrapheneType(DjangoObjectType):

graphene_django/tests/test_forms.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.core.exceptions import ValidationError
22
from py.test import raises
33

4-
from ..forms import GlobalIDFormField
4+
from ..forms import GlobalIDFormField,GlobalIDMultipleChoiceField
55

66

77
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
@@ -18,6 +18,17 @@ def test_global_id_invalid():
1818
field.clean('badvalue')
1919

2020

21+
def test_global_id_multiple_valid():
22+
field = GlobalIDMultipleChoiceField()
23+
field.clean(['TXlUeXBlOmFiYw==', 'TXlUeXBlOmFiYw=='])
24+
25+
26+
def test_global_id_multiple_invalid():
27+
field = GlobalIDMultipleChoiceField()
28+
with raises(ValidationError):
29+
field.clean(['badvalue', 'another bad avue'])
30+
31+
2132
def test_global_id_none():
2233
field = GlobalIDFormField()
2334
with raises(ValidationError):

0 commit comments

Comments
 (0)