Skip to content

Commit 72a0e04

Browse files
committed
We fix the test for the authentification: reusing the setenv function defined in the api package in order to set the proper environment for the test
1 parent e39b3a1 commit 72a0e04

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/authentification/tests/test_template.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
from django.http import HttpRequest
33
from ..views import SignupView
44
from app import settings
5-
5+
from api.tests.test_config import setenv
66

77
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
88
class AddCSSTemplateTagTest(SimpleTestCase):
99

1010
def test_rendered(self):
11+
with setenv('ALLOW_SIGNUP', 'True'):
1112
request = HttpRequest()
1213
request.method = 'GET'
1314
needle = '<input type="password" name="password1" class=" input" required id="id_password1">'
@@ -19,6 +20,7 @@ class ViewsTest(SimpleTestCase):
1920
"""Class for testing views"""
2021

2122
def test_mail_not_set_up(self):
23+
with setenv('ALLOW_SIGNUP', 'True'):
2224
if hasattr(settings, 'EMAIL_HOST'):
2325
has_EMAIL_HOST = True
2426
EMAIL_HOST = settings.EMAIL_HOST
@@ -45,6 +47,7 @@ def test_mail_not_set_up(self):
4547
self.assertInHTML(needle, str(response.content))
4648

4749
def test_signup_not_allowed(self):
50+
with setenv('ALLOW_SIGNUP', 'True'):
4851
ALLOW_SIGNUP = settings.ALLOW_SIGNUP
4952
settings.ALLOW_SIGNUP = False
5053
request = HttpRequest()
@@ -59,6 +62,7 @@ class ViewsDBTest(TestCase):
5962
"""Class for testing views with DB queries"""
6063

6164
def test_form_submission(self):
65+
with setenv('ALLOW_SIGNUP', 'True'):
6266
self.factory = RequestFactory()
6367
if hasattr(settings, 'EMAIL_BACKEND'):
6468
EMAIL_BACKEND = settings.EMAIL_BACKEND

0 commit comments

Comments
 (0)