Exemple #1
0
def get_cool_off_threshold(attempt_time: datetime = None) -> datetime:
    """
    Get threshold for fetching access attempts from the database.
    """

    if attempt_time is None:
        return now() - get_cool_off()

    return attempt_time - get_cool_off()
Exemple #2
0
def get_cool_off_threshold(attempt_time: datetime = None) -> datetime:
    """
    Get threshold for fetching access attempts from the database.
    """

    cool_off = get_cool_off()
    if cool_off is None:
        raise TypeError('Cool off threshold can not be calculated with settings.AXES_COOLOFF_TIME set to None')

    if attempt_time is None:
        return now() - cool_off
    return attempt_time - cool_off
Exemple #3
0
def get_cool_off_threshold(attempt_time: datetime = None) -> datetime:
    """
    Get threshold for fetching access attempts from the database.
    """

    cool_off = get_cool_off()
    if cool_off is None:
        raise TypeError(
            "Cool off threshold can not be calculated with settings.AXES_COOLOFF_TIME set to None"
        )

    if attempt_time is None:
        return now() - cool_off
    return attempt_time - cool_off
Exemple #4
0
 def test_get_cool_off_str(self):
     self.assertEqual(get_cool_off(), timedelta(seconds=30))
Exemple #5
0
 def test_get_cool_off_int(self):
     self.assertEqual(get_cool_off(), timedelta(hours=2))
Exemple #6
0
 def test_get_cool_off_none(self):
     self.assertIsNone(get_cool_off())
Exemple #7
0
 def cool_off(self):
     sleep(get_cool_off().total_seconds())
Exemple #8
0
 def cool_off(self):
     sleep(get_cool_off().total_seconds())