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()
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
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
def test_get_cool_off_str(self): self.assertEqual(get_cool_off(), timedelta(seconds=30))
def test_get_cool_off_int(self): self.assertEqual(get_cool_off(), timedelta(hours=2))
def test_get_cool_off_none(self): self.assertIsNone(get_cool_off())
def cool_off(self): sleep(get_cool_off().total_seconds())
def cool_off(self): sleep(get_cool_off().total_seconds())