本文整理匯總了Python中allauth.account.adapter.DefaultAccountAdapter方法的典型用法代碼示例。如果您正苦於以下問題:Python adapter.DefaultAccountAdapter方法的具體用法?Python adapter.DefaultAccountAdapter怎麽用?Python adapter.DefaultAccountAdapter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類allauth.account.adapter
的用法示例。
在下文中一共展示了adapter.DefaultAccountAdapter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_pre_authenticate_fails
# 需要導入模塊: from allauth.account import adapter [as 別名]
# 或者: from allauth.account.adapter import DefaultAccountAdapter [as 別名]
def test_pre_authenticate_fails(self):
UserFactory.create(username='john_snow', password='Winteriscoming!')
credentials = {'username': 'john_snow', 'password': 'knowsnothing'}
request = self.client.get(
reverse('account:login'),
{'login': 'john_snow', 'password': 'knowsnothing'})
cache_key = all_auth()._get_login_attempts_cache_key(
request, **credentials)
data = []
dt = timezone.now()
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
with pytest.raises(ValidationError):
a().pre_authenticate(request, **credentials)
# fake a user waiting 2 seconds
dt = timezone.now() - timedelta(seconds=2)
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
a().pre_authenticate(request, **credentials)
示例2: test_pre_authenticate_maxes_out
# 需要導入模塊: from allauth.account import adapter [as 別名]
# 或者: from allauth.account.adapter import DefaultAccountAdapter [as 別名]
def test_pre_authenticate_maxes_out(self):
UserFactory.create(username='john_snow', password='Winteriscoming!')
credentials = {'username': 'john_snow', 'password': 'knowsnothing'}
request = self.client.get(
reverse('account:login'),
{'login': 'john_snow', 'password': 'knowsnothing'})
cache_key = all_auth()._get_login_attempts_cache_key(
request, **credentials)
data = [None] * 1000
dt = timezone.now()
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
with pytest.raises(ValidationError):
a().pre_authenticate(request, **credentials)
dt = timezone.now() - timedelta(seconds=ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
data.append(time.mktime(dt.timetuple()))
cache.set(cache_key, data, ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT)
a().pre_authenticate(request, **credentials)