From 65e63026a0d3f2da18a8df1055303ae2cd9f83ad Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 11 Dec 2017 21:23:00 -0500 Subject: [PATCH] Add tests --- .../rest_framework/tests/test_mutation.py | 13 +++++++++++++ graphene_django/tests/test_forms.py | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/graphene_django/rest_framework/tests/test_mutation.py b/graphene_django/rest_framework/tests/test_mutation.py index c34a971..491192a 100644 --- a/graphene_django/rest_framework/tests/test_mutation.py +++ b/graphene_django/rest_framework/tests/test_mutation.py @@ -52,6 +52,19 @@ def test_has_input_fields(): assert 'model' in MyMutation.Input._meta.fields +def test_exclude_fields(): + class MyMutation(SerializerMutation): + class Meta: + serializer_class = MyModelSerializer + exclude_fields = ['created'] + + assert 'cool_name' in MyMutation._meta.fields + assert 'created' not in MyMutation._meta.fields + assert 'errors' in MyMutation._meta.fields + assert 'cool_name' in MyMutation.Input._meta.fields + assert 'created' not in MyMutation.Input._meta.fields + + def test_nested_model(): class MyFakeModelGrapheneType(DjangoObjectType): diff --git a/graphene_django/tests/test_forms.py b/graphene_django/tests/test_forms.py index ada9e8a..b15e866 100644 --- a/graphene_django/tests/test_forms.py +++ b/graphene_django/tests/test_forms.py @@ -1,7 +1,7 @@ from django.core.exceptions import ValidationError from py.test import raises -from ..forms import GlobalIDFormField +from ..forms import GlobalIDFormField,GlobalIDMultipleChoiceField # 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc' @@ -18,6 +18,17 @@ def test_global_id_invalid(): field.clean('badvalue') +def test_global_id_multiple_valid(): + field = GlobalIDMultipleChoiceField() + field.clean(['TXlUeXBlOmFiYw==', 'TXlUeXBlOmFiYw==']) + + +def test_global_id_multiple_invalid(): + field = GlobalIDMultipleChoiceField() + with raises(ValidationError): + field.clean(['badvalue', 'another bad avue']) + + def test_global_id_none(): field = GlobalIDFormField() with raises(ValidationError):