Commit ae79abf4 authored by okhin's avatar okhin

Updating the tests with the title for argumentaries

parent 212fa044
Pipeline #727 passed with stages
in 1 minute and 5 seconds
...@@ -21,9 +21,10 @@ class ArgumentarySerializerTest(TestCase): ...@@ -21,9 +21,10 @@ class ArgumentarySerializerTest(TestCase):
Argumentary.objects.create( Argumentary.objects.create(
lang='en', lang='en',
text='A pertinent argument', text='A pertinent argument',
title='A title',
campaign = campaign campaign = campaign
) )
self.assertEqual(ArgumentarySerializer(Argumentary.objects.all(), many=True).data, [OrderedDict([('lang', 'en'), ('text', 'A pertinent argument')])]) self.assertEqual(ArgumentarySerializer(Argumentary.objects.all(), many=True).data, [OrderedDict([('lang', 'en'), ('text', 'A pertinent argument'), ('title', 'A title')])])
class CampaignContactSerializerTest(TestCase): class CampaignContactSerializerTest(TestCase):
def test_to_representation(self): def test_to_representation(self):
......
...@@ -19,6 +19,7 @@ class ViewSetTest(TestCase): ...@@ -19,6 +19,7 @@ class ViewSetTest(TestCase):
self.argumentary = Argumentary.objects.create( self.argumentary = Argumentary.objects.create(
lang='en', lang='en',
text='A pertinent argument', text='A pertinent argument',
title='A title',
campaign=self.campaign campaign=self.campaign
) )
self.contact = Contact.objects.create( self.contact = Contact.objects.create(
...@@ -52,8 +53,8 @@ class ViewSetTest(TestCase): ...@@ -52,8 +53,8 @@ class ViewSetTest(TestCase):
client = APIClient() client = APIClient()
response = client.get('/campaigns/%(cid)d/arguments/' % {'cid': self.campaign.id}, format='json') response = client.get('/campaigns/%(cid)d/arguments/' % {'cid': self.campaign.id}, format='json')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, b'[{"lang":"en","text":"A pertinent argument"}]') self.assertEqual(response.content, b'[{"lang":"en","text":"A pertinent argument","title":"A title"}]')
response = client.get('/campaigns/%(cid)d/arguments/%(lang)s/' % {'cid': self.campaign.id, 'lang': self.argumentary.lang}, format='json') response = client.get('/campaigns/%(cid)d/arguments/%(lang)s/' % {'cid': self.campaign.id, 'lang': self.argumentary.lang}, format='json')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, b'{"lang":"en","text":"A pertinent argument"}') self.assertEqual(response.content, b'{"lang":"en","text":"A pertinent argument","title":"A title"}')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment