Test mutation

This commit is contained in:
Grant McConnaughey 2017-07-18 10:48:09 -05:00
parent 80a06a0354
commit 4f904f4700

View File

@ -1,4 +1,5 @@
from django import forms
from django.test import TestCase
from py.test import raises
from graphene_django.tests.models import Pet
@ -40,10 +41,23 @@ def test_has_input_fields():
assert 'text' in MyMutation.Input._meta.fields
def test_model_form():
class PetMutation(ModelFormMutation):
class Meta:
form_class = PetForm
class ModelFormMutationTests(TestCase):
assert PetMutation.model == Pet
assert PetMutation.return_field_name == 'pet'
def test_model_form_mutation(self):
class PetMutation(ModelFormMutation):
class Meta:
form_class = PetForm
self.assertEqual(PetMutation.model, 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')