mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
Use single quotes for strings
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
This commit is contained in:
parent
d215485a66
commit
d33a55b927
3 changed files with 13 additions and 11 deletions
|
|
@ -9,6 +9,11 @@ from django.utils import six
|
|||
from axes.utils import iso8601, is_ipv6, get_client_str, get_client_username
|
||||
|
||||
|
||||
def get_expected_client_str(*args, **kwargs):
|
||||
client_str_template = '{{user: "{0}", ip: "{1}", user-agent: "{2}", path: "{3}"}}'
|
||||
return client_str_template.format(*args, **kwargs)
|
||||
|
||||
|
||||
class UtilsTest(TestCase):
|
||||
def test_iso8601(self):
|
||||
"""Tests iso8601 correctly translates datetime.timdelta to ISO 8601
|
||||
|
|
@ -46,8 +51,7 @@ class UtilsTest(TestCase):
|
|||
user_agent = 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)'
|
||||
path_info = '/admin/'
|
||||
|
||||
details = "{{user: '{0}', ip: '{1}', user-agent: '{2}', path: '{3}'}}"
|
||||
expected = details.format(username, ip, user_agent, path_info)
|
||||
expected = get_expected_client_str(username, ip, user_agent, path_info)
|
||||
actual = get_client_str(username, ip, user_agent, path_info)
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
|
@ -72,8 +76,7 @@ class UtilsTest(TestCase):
|
|||
user_agent = 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)'
|
||||
path_info = '/admin/'
|
||||
|
||||
details = "{{user: '{0}', ip: '{1}', user-agent: '{2}', path: '{3}'}}"
|
||||
expected = details.format(username, ip, user_agent, path_info)
|
||||
expected = get_expected_client_str(username, ip, user_agent, path_info)
|
||||
actual = get_client_str(username, ip, user_agent, path_info)
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
|
@ -99,8 +102,7 @@ class UtilsTest(TestCase):
|
|||
user_agent = 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)'
|
||||
path_info = '/admin/'
|
||||
|
||||
details = "{{user: '{0}', ip: '{1}', user-agent: '{2}', path: '{3}'}}"
|
||||
expected = details.format(username, ip, user_agent, path_info)
|
||||
expected = get_expected_client_str(username, ip, user_agent, path_info)
|
||||
actual = get_client_str(username, ip, user_agent, path_info)
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
|
@ -126,8 +128,7 @@ class UtilsTest(TestCase):
|
|||
user_agent = 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)'
|
||||
path_info = '/admin/'
|
||||
|
||||
details = "{{user: '{0}', ip: '{1}', user-agent: '{2}', path: '{3}'}}"
|
||||
expected = details.format(username, ip, user_agent, path_info)
|
||||
expected = get_expected_client_str(username, ip, user_agent, path_info)
|
||||
actual = get_client_str(username, ip, user_agent, path_info)
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def get_client_str(username, ip_address, user_agent=None, path_info=None):
|
|||
if settings.AXES_VERBOSE:
|
||||
if isinstance(path_info, tuple):
|
||||
path_info = path_info[0]
|
||||
details = "{{user: '{0}', ip: '{1}', user-agent: '{2}', path: '{3}'}}"
|
||||
details = '{{user: "{0}", ip: "{1}", user-agent: "{2}", path: "{3}"}}'
|
||||
return details.format(username, ip_address, user_agent, path_info)
|
||||
|
||||
if settings.AXES_ONLY_USER_FAILURES:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "axes.test_settings")
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'axes.test_settings')
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue