fix some codacy errors
This commit is contained in:
@ -284,6 +284,7 @@ class NewVersionWarningTestCase(TestCase):
|
||||
|
||||
@mock.patch("cas_server.models.VERSION", "0.1.2")
|
||||
def test_send_mails(self):
|
||||
"""test the send_mails method with ADMINS and a new version available"""
|
||||
models.NewVersionWarning.send_mails()
|
||||
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
@ -297,16 +298,19 @@ class NewVersionWarningTestCase(TestCase):
|
||||
|
||||
@mock.patch("cas_server.models.VERSION", "1.2.3")
|
||||
def test_send_mails_same_version(self):
|
||||
"""test the send_mails method with with current version being the last"""
|
||||
models.NewVersionWarning.objects.create(version="0.1.2")
|
||||
models.NewVersionWarning.send_mails()
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
@override_settings(ADMINS=[])
|
||||
def test_send_mails_no_admins(self):
|
||||
"""test the send_mails method without ADMINS"""
|
||||
models.NewVersionWarning.send_mails()
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
@override_settings(CAS_NEW_VERSION_EMAIL_WARNING=False)
|
||||
def test_send_mails_disabled(self):
|
||||
"""test the send_mails method if disabled"""
|
||||
models.NewVersionWarning.send_mails()
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
@ -136,9 +136,12 @@ class CheckPasswordCase(TestCase):
|
||||
"""test all the hex_HASH method: the hashed password is a simple hash of the password"""
|
||||
hashes = ["md5", "sha1", "sha224", "sha256", "sha384", "sha512"]
|
||||
hashed_password1 = []
|
||||
for hash in hashes:
|
||||
for hash_scheme in hashes:
|
||||
hashed_password1.append(
|
||||
("hex_%s" % hash, getattr(utils.hashlib, hash)(self.password1).hexdigest())
|
||||
(
|
||||
"hex_%s" % hash_scheme,
|
||||
getattr(utils.hashlib, hash_scheme)(self.password1).hexdigest()
|
||||
)
|
||||
)
|
||||
for (method, hp1) in hashed_password1:
|
||||
self.assertTrue(utils.check_password(method, self.password1, hp1, "utf8"))
|
||||
|
@ -52,6 +52,7 @@ class LoginTestCase(TestCase, BaseServicePattern, CanLogin):
|
||||
@mock.patch("cas_server.utils.last_version", lambda: "1.2.3")
|
||||
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
||||
def test_new_version_available_ok(self):
|
||||
"""test the new version info box"""
|
||||
client = Client()
|
||||
response = client.get("/login")
|
||||
self.assertIn(b"A new version of the application is available", response.content)
|
||||
@ -60,12 +61,16 @@ class LoginTestCase(TestCase, BaseServicePattern, CanLogin):
|
||||
@mock.patch("cas_server.utils.last_version", lambda: None)
|
||||
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
||||
def test_new_version_available_badpypi(self):
|
||||
"""
|
||||
test the new version info box if pypi is not available (unable to retreive last version)
|
||||
"""
|
||||
client = Client()
|
||||
response = client.get("/login")
|
||||
self.assertNotIn(b"A new version of the application is available", response.content)
|
||||
|
||||
@override_settings(CAS_NEW_VERSION_HTML_WARNING=False)
|
||||
def test_new_version_available_disabled(self):
|
||||
"""test the new version info box is disabled"""
|
||||
client = Client()
|
||||
response = client.get("/login")
|
||||
self.assertNotIn(b"A new version of the application is available", response.content)
|
||||
|
@ -33,6 +33,11 @@ if django.VERSION < (1, 8):
|
||||
from django.template import Context
|
||||
else:
|
||||
def Context(arg):
|
||||
"""
|
||||
Starting from django 1.8 render take a dict and deprecated the use of a Context.
|
||||
So this is the identity function, only use for compatibility with django 1.7 where
|
||||
render MUST take a Context as argument.
|
||||
"""
|
||||
return arg
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user