tests.py 3.21 KB
Newer Older
1
from django.conf import settings
Aymeric Barantal's avatar
Aymeric Barantal committed
2
3
from django.test import TestCase

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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(
95
96
            str(campaigncontact),
            "Contact Contact object on Campaign Title"
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
        )

    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(),[])