From bf4861f595bfee11102ca463bdd70364f911db14 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Mon, 10 Sep 2018 14:28:08 +0200 Subject: [PATCH] Add more tests Also, add test settings --- server/book/tests/test_module_mutations.py | 18 +++++++++++++++--- server/core/settings_test.py | 12 ++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 server/core/settings_test.py diff --git a/server/book/tests/test_module_mutations.py b/server/book/tests/test_module_mutations.py index 7c4d4b49..369e4692 100644 --- a/server/book/tests/test_module_mutations.py +++ b/server/book/tests/test_module_mutations.py @@ -7,7 +7,7 @@ from graphene.test import Client from graphql_relay import to_global_id 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.models import ContentBlock @@ -25,10 +25,13 @@ class NewContentBlockMutationTest(TestCase): mutation = get_graphql_mutation('addContentBlock.gql') - executed = client.execute(mutation, variables={ + title = "Hello World" + + result = client.execute(mutation, variables={ 'input': { "contentBlock": { - "title": "Hello World", "contents": [ + "title": title, + "contents": [ { "type": "text_block", "text": "Hello there" @@ -38,4 +41,13 @@ class NewContentBlockMutationTest(TestCase): "after": self.sibling_id } }) + self.assertIsNone(result.get('errors')) 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) diff --git a/server/core/settings_test.py b/server/core/settings_test.py new file mode 100644 index 00000000..1ad6e870 --- /dev/null +++ b/server/core/settings_test.py @@ -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()