Skip to content

Commit a52d132

Browse files
author
Guillim
committed
Small fix in order to follow Circle CI instruction
1 parent 13fe8ad commit a52d132

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

app/authentification/tests/test_activate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.test import RequestFactory, TestCase
1+
from django.test import RequestFactory, TestCase, override_settings
22
from django.utils.http import urlsafe_base64_encode
33
from django.utils.encoding import force_bytes
44
from django.urls import reverse
@@ -8,6 +8,7 @@
88
import re
99

1010

11+
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
1112
class TestActivate(TestCase):
1213
def setUp(self):
1314
# Every test needs access to the request factory.

app/authentification/tests/test_template.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from django.test import SimpleTestCase, TestCase, RequestFactory
1+
from django.test import SimpleTestCase, TestCase, RequestFactory, override_settings
22
from django.http import HttpRequest
33
from ..views import SignupView
44
from app import settings
55

66

7+
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
78
class AddCSSTemplateTagTest(SimpleTestCase):
89

910
def test_rendered(self):
@@ -13,6 +14,7 @@ def test_rendered(self):
1314
self.assertInHTML(needle, str(SignupView.as_view()(request, as_string=True).content))
1415

1516

17+
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
1618
class ViewsTest(SimpleTestCase):
1719
"""Class for testing views"""
1820

@@ -52,12 +54,17 @@ def test_signup_not_allowed(self):
5254
self.assertEqual(response.status_code, 302)
5355

5456

57+
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
5558
class ViewsDBTest(TestCase):
5659
"""Class for testing views with DB queries"""
5760

5861
def test_form_submission(self):
5962
self.factory = RequestFactory()
60-
EMAIL_BACKEND = settings.EMAIL_BACKEND
63+
if hasattr(settings, 'EMAIL_BACKEND'):
64+
EMAIL_BACKEND = settings.EMAIL_BACKEND
65+
else:
66+
EMAIL_BACKEND = False
67+
6168
settings.EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
6269
request = self.factory.post('/signup')
6370
request.POST = {'username': 'username5648',
@@ -67,5 +74,8 @@ def test_form_submission(self):
6774
}
6875
response = SignupView.as_view()(request)
6976
needle = '<span>emailed you instructions to activate your account</span>'
70-
settings.EMAIL_BACKEND = EMAIL_BACKEND
77+
if not EMAIL_BACKEND:
78+
delattr(settings, 'EMAIL_BACKEND')
79+
else:
80+
settings.EMAIL_BACKEND = EMAIL_BACKEND
7181
self.assertInHTML(needle, str(response.content))

0 commit comments

Comments
 (0)