mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 09:37:07 +03:00
Test mutation
This commit is contained in:
parent
80a06a0354
commit
4f904f4700
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user