本文整理匯總了Python中django.contrib.messages.storage.base.BaseStorage方法的典型用法代碼示例。如果您正苦於以下問題:Python base.BaseStorage方法的具體用法?Python base.BaseStorage怎麽用?Python base.BaseStorage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.messages.storage.base
的用法示例。
在下文中一共展示了base.BaseStorage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_social_account_adapter_signup
# 需要導入模塊: from django.contrib.messages.storage import base [as 別名]
# 或者: from django.contrib.messages.storage.base import BaseStorage [as 別名]
def test_social_account_adapter_signup(self):
"""Test that our Allauth social account adapter correctly handles signups."""
adapter = SocialAccountAdapter()
discord_login = SocialLogin(account=self.discord_account)
discord_login_role = SocialLogin(account=self.discord_account_role)
discord_login_two_roles = SocialLogin(account=self.discord_account_two_roles)
discord_login_not_present = SocialLogin(account=self.discord_account_not_present)
github_login = SocialLogin(account=self.github_account)
messages_request = HttpRequest()
messages_request._messages = BaseStorage(messages_request)
with patch("pydis_site.utils.account.reverse") as mock_reverse:
with patch("pydis_site.utils.account.redirect") as mock_redirect:
with self.assertRaises(ImmediateHttpResponse):
adapter.is_open_for_signup(messages_request, github_login)
with self.assertRaises(ImmediateHttpResponse):
adapter.is_open_for_signup(messages_request, discord_login)
with self.assertRaises(ImmediateHttpResponse):
adapter.is_open_for_signup(messages_request, discord_login_role)
with self.assertRaises(ImmediateHttpResponse):
adapter.is_open_for_signup(messages_request, discord_login_not_present)
self.assertEqual(len(messages_request._messages._queued_messages), 4)
self.assertEqual(mock_redirect.call_count, 4)
self.assertEqual(mock_reverse.call_count, 4)
self.assertTrue(adapter.is_open_for_signup(HttpRequest(), discord_login_two_roles))