Commit 0e331d24 authored by Mindiell's avatar Mindiell

Add tests on campaign models, and correction in models

parent a244d055
......@@ -22,7 +22,7 @@ class Campaign(models.Model):
verbose_name=_('language'))
def __unicode__(self):
return self.title
return self.title.decode('utf-8')
class Argumentary(models.Model):
......
from django.conf import settings
from django.test import TestCase
# Create your tests here.
from picampaign.campaign.models import Campaign, Argumentary, CampaignContact
from picampaign.contact.models import Contact
class CampaignMethodTests(TestCase):
def test_unicode_is_title(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
self.assertEqual(campaign.__unicode__(), 'Campaign Title')
def test_unicode_is_unicode(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
self.assertEqual(
str(type(campaign.__unicode__())),
"<type 'unicode'>"
)
class ArgumentaryMethodTests(TestCase):
def test_unicode_is_title(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
argumentary = Argumentary(
campaign=campaign,
lang='en'
)
self.assertEqual(
argumentary.__unicode__(),
"Argumentary in en for Campaign Title"
)
def test_unicode_is_unicode(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
argumentary = Argumentary(
campaign=campaign,
lang='en'
)
self.assertEqual(
str(type(argumentary.__unicode__())),
"<type 'unicode'>"
)
class CampaignContactMethodTests(TestCase):
def test_unicode_is_contact_and_title(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
contact = Contact(
first_name='Victor',
last_name='Hugo',
phone='+3312345678'
)
campaigncontact = CampaignContact(
campaign=campaign,
contact=contact
)
self.assertEqual(
campaigncontact.__unicode__(),
"Contact Victor Hugo on Campaign Title"
)
def test_unicode_is_unicode(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
contact = Contact(
first_name='Victor',
last_name='Hugo',
phone='+3312345678'
)
campaigncontact = CampaignContact(
campaign=campaign,
contact=contact
)
self.assertEqual(
str(type(campaigncontact.__unicode__())),
"<type 'unicode'>"
)
def test_all_groups_is_empty(self):
campaign = Campaign(
title='Campaign Title',
start_date='2000-01-01',
end_date='2100-12-31'
)
contact = Contact(
first_name='Victor',
last_name='Hugo',
phone='+3312345678'
)
campaigncontact = CampaignContact(
campaign=campaign,
contact=contact
)
self.assertEqual(campaigncontact.all_groups(),[])
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