Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 4
0
 def test_get_cool_off_str(self):
     self.assertEqual(get_cool_off(), timedelta(seconds=30))
Exemplo n.º 5
0
 def test_get_cool_off_int(self):
     self.assertEqual(get_cool_off(), timedelta(hours=2))
Exemplo n.º 6
0
 def test_get_cool_off_none(self):
     self.assertIsNone(get_cool_off())
Exemplo n.º 7
0
 def cool_off(self):
     sleep(get_cool_off().total_seconds())
Exemplo n.º 8
0
 def cool_off(self):
     sleep(get_cool_off().total_seconds())