diff --git a/server/book/tests/__init__.py b/server/book/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/server/book/tests/test_module_mutations.py b/server/book/tests/test_module_mutations.py new file mode 100644 index 00000000..7e780a65 --- /dev/null +++ b/server/book/tests/test_module_mutations.py @@ -0,0 +1,40 @@ +import io +import os + +from django.test import TestCase + +from graphene.test import Client +from graphql_relay import to_global_id + +from api.schema import schema +from book.factories import ContentBlockFactory +from book.models import ContentBlock + +from django.conf import settings + + +class NewContentBlockMutationTest(TestCase): + def setUp(self): + content_block = ContentBlockFactory() + self.sibling_id = to_global_id('ContentBlock', content_block.pk) + + def test_add_new_content_block(self): + self.assertEqual(ContentBlock.objects.count(), 1) + client = Client(schema=schema) + with io.open(os.path.join(settings.GRAPHQL_MUTATIONS_DIR, 'addContentBlock.gql')) as f: + mutation = f.read() + + executed = client.execute(mutation, variables={ + 'input': { + "contentBlock": { + "title": "Hello World", "contents": [ + { + "type": "text_block", + "text": "Hello there" + } + ] + }, + "after": self.sibling_id + } + }) + self.assertEqual(ContentBlock.objects.count(), 2) diff --git a/server/core/settings.py b/server/core/settings.py index 1d6ce8b3..34c83c8c 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -43,13 +43,6 @@ if not DEBUG: # Application definition INSTALLED_APPS = [ - 'core', - 'api', - 'user', - 'book', - 'objectives', - 'rooms', - 'wagtail.contrib.forms', 'wagtail.contrib.redirects', 'wagtail.embeds', @@ -78,6 +71,13 @@ INSTALLED_APPS = [ 'graphene_django', 'django_extensions', 'compressor', + + 'core', + 'api', + 'user', + 'book.apps.BookConfig', + 'objectives', + 'rooms', ] if DEBUG: @@ -332,4 +332,7 @@ if DEBUG: ] # http://docs.wagtail.io/en/v2.1/advanced_topics/settings.html?highlight=urls -WAGTAIL_SITE_NAME = 'skillBox' +WAGTAIL_SITE_NAME = 'skillbox' + +GRAPHQL_QUERIES_DIR = os.path.join(BASE_DIR, '..', 'client', 'src', 'graphql', 'gql') +GRAPHQL_MUTATIONS_DIR = os.path.join(GRAPHQL_QUERIES_DIR, 'mutations')