Add more tests

Also, add test settings
This commit is contained in:
Ramon Wenger 2018-09-10 14:28:08 +02:00
parent 370fd54b98
commit bf4861f595
2 changed files with 27 additions and 3 deletions

View File

@ -7,7 +7,7 @@ from graphene.test import Client
from graphql_relay import to_global_id from graphql_relay import to_global_id
from api.schema import schema from api.schema import schema
from api.utils import get_graphql_mutation from api.utils import get_graphql_mutation, get_object
from book.factories import ContentBlockFactory from book.factories import ContentBlockFactory
from book.models import ContentBlock from book.models import ContentBlock
@ -25,10 +25,13 @@ class NewContentBlockMutationTest(TestCase):
mutation = get_graphql_mutation('addContentBlock.gql') mutation = get_graphql_mutation('addContentBlock.gql')
executed = client.execute(mutation, variables={ title = "Hello World"
result = client.execute(mutation, variables={
'input': { 'input': {
"contentBlock": { "contentBlock": {
"title": "Hello World", "contents": [ "title": title,
"contents": [
{ {
"type": "text_block", "type": "text_block",
"text": "Hello there" "text": "Hello there"
@ -38,4 +41,13 @@ class NewContentBlockMutationTest(TestCase):
"after": self.sibling_id "after": self.sibling_id
} }
}) })
self.assertIsNone(result.get('errors'))
self.assertEqual(ContentBlock.objects.count(), 2) self.assertEqual(ContentBlock.objects.count(), 2)
new_content_block = result.get('data').get('addContentBlock').get('newContentBlock')
self.assertEqual(new_content_block.get('title'), title)
id = new_content_block.get('id')
content_block_page = get_object(ContentBlock, id)
self.assertEqual(content_block_page.title, title)

View File

@ -0,0 +1,12 @@
from .settings import *
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return None
MIGRATION_MODULES = DisableMigrations()