mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-26 12:03:47 +03:00
Test mutation
This commit is contained in:
parent
80a06a0354
commit
4f904f4700
|
@ -1,4 +1,5 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.test import TestCase
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
|
|
||||||
from graphene_django.tests.models import Pet
|
from graphene_django.tests.models import Pet
|
||||||
|
@ -40,10 +41,23 @@ def test_has_input_fields():
|
||||||
assert 'text' in MyMutation.Input._meta.fields
|
assert 'text' in MyMutation.Input._meta.fields
|
||||||
|
|
||||||
|
|
||||||
def test_model_form():
|
class ModelFormMutationTests(TestCase):
|
||||||
|
|
||||||
|
def test_model_form_mutation(self):
|
||||||
class PetMutation(ModelFormMutation):
|
class PetMutation(ModelFormMutation):
|
||||||
class Meta:
|
class Meta:
|
||||||
form_class = PetForm
|
form_class = PetForm
|
||||||
|
|
||||||
assert PetMutation.model == Pet
|
self.assertEqual(PetMutation.model, Pet)
|
||||||
assert PetMutation.return_field_name == 'pet'
|
self.assertEqual(PetMutation.return_field_name, 'pet')
|
||||||
|
|
||||||
|
def test_model_form_mutation_mutate(self):
|
||||||
|
class PetMutation(ModelFormMutation):
|
||||||
|
class Meta:
|
||||||
|
form_class = PetForm
|
||||||
|
|
||||||
|
PetMutation.mutate(None, {'input': {'name': 'Fluffy'}}, None, None)
|
||||||
|
|
||||||
|
self.assertEqual(Pet.objects.count(), 1)
|
||||||
|
pet = Pet.objects.get()
|
||||||
|
self.assertEqual(pet.name, 'Fluffy')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user