Update unit test
This commit is contained in:
parent
3403c2db3d
commit
e843f6be6a
|
|
@ -1,14 +1,15 @@
|
||||||
from unittest import TestCase
|
from django.test import TestCase
|
||||||
from graphene.test import Client
|
from graphene.test import Client
|
||||||
|
|
||||||
from api.schema import schema
|
from api.schema import schema
|
||||||
from news.factories import NewsTeaserFactory
|
from news.factories import NewsTeaserFactory
|
||||||
|
from news.models import NewsTeaser
|
||||||
|
|
||||||
|
|
||||||
class NewsTeaserTests(TestCase):
|
class NewsTeaserTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.news_teaser1 = NewsTeaserFactory(order_id=1)
|
self.news_teaser1 = NewsTeaserFactory(order_id=1, title="should come first")
|
||||||
self.news_teaser2 = NewsTeaserFactory(order_id=2)
|
self.news_teaser2 = NewsTeaserFactory(order_id=2, title="should be second")
|
||||||
|
|
||||||
self.client = Client(schema=schema)
|
self.client = Client(schema=schema)
|
||||||
|
|
||||||
|
|
@ -16,17 +17,13 @@ class NewsTeaserTests(TestCase):
|
||||||
query = '''
|
query = '''
|
||||||
query NewsTeasers {
|
query NewsTeasers {
|
||||||
newsTeasers {
|
newsTeasers {
|
||||||
edges {
|
id
|
||||||
node {
|
description
|
||||||
id
|
title
|
||||||
description
|
imageUrl
|
||||||
title
|
newsArticleUrl
|
||||||
imageUrl
|
displayDate
|
||||||
newsArticleUrl
|
imageSource
|
||||||
displayDate
|
|
||||||
imageSource
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
@ -36,7 +33,7 @@ class NewsTeaserTests(TestCase):
|
||||||
def test_can_get_news_teaser(self):
|
def test_can_get_news_teaser(self):
|
||||||
result = self.make_query()
|
result = self.make_query()
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.get('errors'))
|
||||||
news_teasers = result.get('data').get('newsTeasers').get('edges')
|
news_teasers = result.get('data').get('newsTeasers')
|
||||||
self.assertEqual(news_teasers[0].get('node').get('title'), self.news_teaser1.title)
|
self.assertEqual(news_teasers[0].get('title'), self.news_teaser1.title)
|
||||||
self.assertEqual(news_teasers[1].get('node').get('title'), self.news_teaser2.title)
|
self.assertEqual(news_teasers[1].get('title'), self.news_teaser2.title)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue