test_models.py 1.71 KB
Newer Older
1
from django.conf import settings
Aymeric Barantal's avatar
Aymeric Barantal committed
2
from django.test import TestCase
okhin's avatar
okhin committed
3
from django.contrib.auth.models import User
Aymeric Barantal's avatar
Aymeric Barantal committed
4

5
from picampaign.campaign.models import Campaign, CampaignContact, Argumentary
6
from picampaign.contact.models import Contact
okhin's avatar
okhin committed
7
from picampaign.campaign.admin import CampaignAdmin
8

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ArgumentaryMethodTests(TestCase):
    def test_str(self):
        campaign = Campaign(
            title='Campaign Title',
            start_date='2000-01-01',
            end_date='2100-12-31'
        )
        argumentary = Argumentary(
            campaign=campaign,
            lang='fr',
            text='Argument number 1'
        )
        self.assertEqual(str(argumentary), 'Argumentary in fr for Campaign Title')

class CampaignMethodTests(TestCase):
    def test_str(self):
25
26
27
28
29
        campaign = Campaign(
            title='Campaign Title',
            start_date='2000-01-01',
            end_date='2100-12-31'
        )
30
31
32
33
34
35
36
37
38
39
        self.assertEqual(str(campaign), campaign.title)

class CampaignContactMethodTests(TestCase):
    def setUp(self):
        self.campaign = Campaign(
            title='Campaign Title',
            start_date='2000-01-01',
            end_date='2100-12-31'
        )
        self.contact = Contact.objects.create(
40
41
            first_name='Victor',
            last_name='Hugo',
42
            birthdate='1802-02-26',
43
        )
44
45
46
        self.campaigncontact = CampaignContact(
            campaign=self.campaign,
            contact=self.contact
47
48
        )

49
50
51
52
53
    def test_all_groups_is_empty(self):
        self.assertEqual(self.campaigncontact.all_groups(),[])

    def test_str(self):
        self.assertEqual(str(self.campaigncontact), 'Contact %(contact)s on %(title)s' % {'contact': self.contact, 'title': self.campaign.title})