Add unit test

This commit is contained in:
Ramon Wenger 2022-05-19 18:33:45 +02:00
parent ad560bb4ef
commit ce9d58ad5c
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
from graphql.error import GraphQLLocatedError
from core.tests.base_test import SkillboxTestCase
TOPIC_QUERY = """
query TopicQuery($slug: String!) {
topic(slug: $slug) {
__typename
...on TopicNode {
title
}
...on NotFound {
reason
}
}
}
"""
class ContentBlockTestCase(SkillboxTestCase):
def setUp(self) -> None:
self.createDefault()
self.client = self.get_client()
def test_topic(self):
slug = "non-existing"
result = self.client.execute(TOPIC_QUERY, variables={
"slug": slug
})
self.assertIsNone(result.get('errors'))
topic = result.get('data').get('topic')
self.assertEqual(topic.get('__typename'), 'NotFound')
self.assertEqual(topic.get('reason'), 'Not Found')