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