11import pytest
2- from django .conf import settings
32from django .core import mail
43from mailer .engine import send_all
54from mailer .models import Message
87from django_ilmoitin .utils import render_notification_template , send_notification
98
109
10+ @pytest .mark .django_db
1111def test_notification_template_rendering (notification_template ):
1212 context = {
1313 "extra_var" : "foo" ,
@@ -31,6 +31,7 @@ def test_notification_template_rendering(notification_template):
3131 assert rendered .body_text == "testitekstiruumis, muuttujan arvo: text_baz!"
3232
3333
34+ @pytest .mark .django_db
3435def test_notification_template_rendering_no_body_text_provided (notification_template ):
3536 context = {
3637 "extra_var" : "foo" ,
@@ -60,6 +61,7 @@ def test_notification_template_rendering_no_body_text_provided(notification_temp
6061 assert rendered .body_text == "testihötömölöruumis, muuttujan arvo: html_baz!"
6162
6263
64+ @pytest .mark .django_db
6365def test_undefined_rendering_context_variable (notification_template ):
6466 context = {"extra_var" : "foo" , "subject_var" : "bar" , "body_text_var" : "baz" }
6567
@@ -70,7 +72,8 @@ def test_undefined_rendering_context_variable(notification_template):
7072 assert "'body_html_var' is undefined" in str (e .value )
7173
7274
73- def test_notification_sending (notification_template ):
75+ @pytest .mark .django_db
76+ def test_notification_sending (notification_template , settings ):
7477 context = {
7578 "extra_var" : "foo" ,
7679 "subject_var" : "bar" ,
@@ -97,6 +100,7 @@ def test_notification_sending(notification_template):
97100
98101
99102@pytest .mark .parametrize ("language" , ["fi" , "en" ])
103+ @pytest .mark .django_db
100104def test_translated_from_email (notification_template , settings , language ):
101105 context = {
102106 "extra_var" : "foo" ,
@@ -115,7 +119,8 @@ def test_translated_from_email(notification_template, settings, language):
115119 )
116120
117121
118- def test_notification_delayed_sending (notification_template ):
122+ @pytest .mark .django_db
123+ def test_notification_delayed_sending (notification_template , settings ):
119124 context = {
120125 "extra_var" : "foo" ,
121126 "subject_var" : "bar" ,
0 commit comments