Révision 6a3e75ef
Ajouté par Serghei Mihai (congés, retour 15/05) il y a presque 8 ans
tests/test_emailing.py | ||
---|---|---|
5 | 5 |
|
6 | 6 |
from django.core.urlresolvers import reverse |
7 | 7 |
from django.utils.http import urlencode |
8 |
from django.core import mail |
|
8 |
from django.core import mail, signing
|
|
9 | 9 |
from django.utils import timezone |
10 | 10 |
from django.core.files.storage import DefaultStorage |
11 |
from django.core.urlresolvers import reverse |
|
11 | 12 |
|
12 | 13 |
from corbo.models import Category, Announce, Subscription, Broadcast |
13 | 14 |
from corbo.models import channel_choices |
... | ... | |
91 | 92 |
assert storage.url(image_name) in mail.outbox[0].attachments.keys() |
92 | 93 |
mail.outbox = [] |
93 | 94 |
storage.delete(image_name) |
95 |
|
|
96 |
def test_unsubscription_link(app, categories, announces): |
|
97 |
for category in categories: |
|
98 |
uuid = uuid4() |
|
99 |
email = '%s@example.net' % uuid |
|
100 |
s = Subscription.objects.create(category=category, |
|
101 |
identifier=email, |
|
102 |
uuid=str(uuid)) |
|
103 |
for announce in announces: |
|
104 |
if announce.category != category: |
|
105 |
continue |
|
106 |
broadcast= Broadcast.objects.get(announce=announce) |
|
107 |
broadcast.send() |
|
108 |
assert broadcast.result |
|
109 |
assert mail.outbox |
|
110 |
signature = signing.dumps({'category': announce.category.pk, |
|
111 |
'identifier': email}) |
|
112 |
unsubscription_link = reverse('unsubscribe', kwargs={'unsubscription_token': signature}) |
|
113 |
assert mail.outbox[0].subject == announce.title |
|
114 |
assert unsubscription_link in mail.outbox[0].html |
|
115 |
assert unsubscription_link in mail.outbox[0].text |
|
116 |
mail.outbox = [] |
Formats disponibles : Unified diff
unsubscribe link (#10795)