本文整理汇总了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))