Add a first test
This commit is contained in:
parent
9362fdb4e2
commit
7142e3f3b1
|
|
@ -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)
|
||||||
|
|
@ -43,13 +43,6 @@ if not DEBUG:
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'core',
|
|
||||||
'api',
|
|
||||||
'user',
|
|
||||||
'book',
|
|
||||||
'objectives',
|
|
||||||
'rooms',
|
|
||||||
|
|
||||||
'wagtail.contrib.forms',
|
'wagtail.contrib.forms',
|
||||||
'wagtail.contrib.redirects',
|
'wagtail.contrib.redirects',
|
||||||
'wagtail.embeds',
|
'wagtail.embeds',
|
||||||
|
|
@ -78,6 +71,13 @@ INSTALLED_APPS = [
|
||||||
'graphene_django',
|
'graphene_django',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'compressor',
|
'compressor',
|
||||||
|
|
||||||
|
'core',
|
||||||
|
'api',
|
||||||
|
'user',
|
||||||
|
'book.apps.BookConfig',
|
||||||
|
'objectives',
|
||||||
|
'rooms',
|
||||||
]
|
]
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
|
@ -332,4 +332,7 @@ if DEBUG:
|
||||||
]
|
]
|
||||||
|
|
||||||
# http://docs.wagtail.io/en/v2.1/advanced_topics/settings.html?highlight=urls
|
# 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')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue