mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-26 03:24:07 +03:00
Add tests
This commit is contained in:
parent
24706f50d4
commit
65e63026a0
|
@ -52,6 +52,19 @@ def test_has_input_fields():
|
||||||
assert 'model' in MyMutation.Input._meta.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():
|
def test_nested_model():
|
||||||
|
|
||||||
class MyFakeModelGrapheneType(DjangoObjectType):
|
class MyFakeModelGrapheneType(DjangoObjectType):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from ..forms import GlobalIDFormField
|
from ..forms import GlobalIDFormField,GlobalIDMultipleChoiceField
|
||||||
|
|
||||||
|
|
||||||
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
|
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
|
||||||
|
@ -18,6 +18,17 @@ def test_global_id_invalid():
|
||||||
field.clean('badvalue')
|
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():
|
def test_global_id_none():
|
||||||
field = GlobalIDFormField()
|
field = GlobalIDFormField()
|
||||||
with raises(ValidationError):
|
with raises(ValidationError):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user