Newer
Older
1
2
3
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
from django.core import mail
import pytest
from gregui import mailutils
@pytest.mark.django_db
def test_registration_template():
prefilled_template = """Dette er en automatisk generert melding fra gjestregistreringstjenesten.
Du har blitt registrert som gjest på UiO av Foo Bar.
For å fullføre registreringen av gjestekontoen følg denne lenken: www.google.com
This message has been automatically generated by the guest registration system.
You have been registered as a guest at UiO by Foo Bar.
To complete the registration of your guest account, please follow this link: www.google.com
"""
rendered_template = mailutils.registration_template("UiO", "Foo Bar")
assert rendered_template == prefilled_template
@pytest.mark.django_db
def test_confirmation_template():
prefilled_template = """Dette er en automatisk generert melding fra gjestregistreringstjenesten.
Din gjest, Foo Bar, har fullført registrering, bekreft gjesten her: www.google.com
This message has been automatically generated by the guest registration system.
Your guest, Foo Bar, has completed their registration, please confirm the guest here: www.google.com
"""
rendered_template = mailutils.confirmation_template("Foo Bar")
assert rendered_template == prefilled_template
@pytest.mark.django_db
def test_registration_mail():
mail.outbox = []
assert mailutils.send_registration_mail("test@example.no", "Foo") == 1
assert len(mail.outbox) == 1
assert mail.outbox[0].to == ["test@example.no"]
@pytest.mark.django_db
def test_confirmation_mail():
mail.outbox = []
assert mailutils.send_confirmation_mail("test@example.no", "Foo") == 1
assert len(mail.outbox) == 1
assert mail.outbox[0].to == ["test@example.no"]