Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
0e331d24
Commit
0e331d24
authored
Jan 15, 2015
by
Mindiell
Browse files
Add tests on campaign models, and correction in models
parent
a244d055
Changes
2
Hide whitespace changes
Inline
Side-by-side
picampaign/campaign/models.py
View file @
0e331d24
...
...
@@ -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
):
...
...
picampaign/campaign/tests.py
View file @
0e331d24
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
(),[])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment