diff --git a/axes/test_settings.py b/axes/test_settings.py index b8a47d4..46ba0b5 100644 --- a/axes/test_settings.py +++ b/axes/test_settings.py @@ -1,5 +1,3 @@ -from datetime import timedelta - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -55,4 +53,3 @@ USE_TZ = False LOGIN_REDIRECT_URL = '/admin/' AXES_LOGIN_FAILURE_LIMIT = 10 -AXES_COOLOFF_TIME = timedelta(seconds=2) diff --git a/axes/tests.py b/axes/tests.py index 1ce899e..f12702f 100644 --- a/axes/tests.py +++ b/axes/tests.py @@ -16,13 +16,15 @@ from django.utils import six from django.test.client import RequestFactory from axes.decorators import get_ip, get_cache_key -from axes.settings import COOLOFF_TIME from axes.settings import FAILURE_LIMIT from axes.models import AccessAttempt, AccessLog from axes.signals import user_locked_out from axes.utils import reset, iso8601 +TEST_COOLOFF_TIME = datetime.timedelta(seconds=2) + + class MockRequest: def __init__(self): self.META = dict() @@ -140,17 +142,19 @@ class AccessAttemptTest(TestCase): self.assertNotEquals(AccessLog.objects.latest('id').logout_time, None) self.assertContains(response, 'Logged out') + @patch('axes.decorators.COOLOFF_TIME', TEST_COOLOFF_TIME) def test_cooling_off(self): """Tests if the cooling time allows a user to login """ self.test_failure_limit_once() # Wait for the cooling off period - time.sleep(COOLOFF_TIME.total_seconds()) + time.sleep(TEST_COOLOFF_TIME.total_seconds()) # It should be possible to login again, make sure it is. self.test_valid_login() + @patch('axes.decorators.COOLOFF_TIME', TEST_COOLOFF_TIME) def test_cooling_off_for_trusted_user(self): """Test the cooling time for a trusted user """