当前位置: 首页>>代码示例>>Python>>正文


Python HttpRequest._messages方法代码示例

本文整理汇总了Python中django.http.request.HttpRequest._messages方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest._messages方法的具体用法?Python HttpRequest._messages怎么用?Python HttpRequest._messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http.request.HttpRequest的用法示例。


在下文中一共展示了HttpRequest._messages方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_request

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import _messages [as 别名]
 def get_request(self):
     request = HttpRequest()
     request.META['REMOTE_ADDR'] = '1.2.3.4'
     request.method = 'POST'
     request.session = SessionStore()
     request._messages = default_storage(request)
     request.user = AnonymousUser()
     return request
开发者ID:nijel,项目名称:weblate,代码行数:10,代码来源:test_ratelimit.py

示例2: test_response_whitout_GET

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import _messages [as 别名]
    def test_response_whitout_GET(self):
        from django.contrib.messages.storage import default_storage

        request = HttpRequest()
        request.session = SessionStore('asd')
        request._messages = default_storage(request)

        response = easy.action_response(request)

        self.assertEqual(len(request._messages._queued_messages), 0)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['Location'], '.')
开发者ID:ebertti,项目名称:django-admin-easy,代码行数:14,代码来源:tests.py

示例3: test_not_exist_view

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import _messages [as 别名]
    def test_not_exist_view(self):
        from django.contrib.messages.storage import default_storage

        request = HttpRequest()
        request.session = SessionStore('asd')
        request._messages = default_storage(request)

        response1 = self.admin.easy_list_view(request, 'not')
        response2 = self.admin.easy_object_view(request, 1, 'not')

        self.assertEqual(response1.status_code, 302)
        self.assertEqual(response2.status_code, 302)
        self.assertEqual(len(request._messages._queued_messages), 2)
开发者ID:GabLeRoux,项目名称:django-admin-easy,代码行数:15,代码来源:tests.py

示例4: test_response_without_querystring

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import _messages [as 别名]
    def test_response_without_querystring(self):
        from django.contrib.messages.storage import default_storage

        request = HttpRequest()
        request.GET = QueryDict('test=asd')
        request.session = SessionStore('asd')
        request._messages = default_storage(request)

        response = easy.action_response(request, 'Some message', keep_querystring=False)

        self.assertEqual(len(request._messages._queued_messages), 1)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['Location'], '.')
开发者ID:ebertti,项目名称:django-admin-easy,代码行数:15,代码来源:tests.py

示例5: has_perm

# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import _messages [as 别名]
from generic_admin.sites import SiteWithTableEditor
from generic_admin.mixins import PermissionsControl, ChangeItemsStateActions, AutoCreateRedirects

from tests.models import MockEntity


class MockSuperUser:
    def has_perm(self, perm):
        return True

request = HttpRequest()
request.user = MockSuperUser()
request.session = 'session'
messages = FallbackStorage(request)
request._messages = messages


class TestMixins(TestCase):
    def setUp(self):
        self.entity = MockEntity.objects.create(name='Test')
        self.site = SiteWithTableEditor()

    def test_permissions_control(self):
        ma = PermissionsControl(MockEntity, self.site)  # ModelAdmin
        permission_checks = [
            ma.has_add_permission, ma.has_change_permission, ma.has_delete_permission
        ]

        for check in permission_checks:
            self.assertTrue(check(request))
开发者ID:fidals,项目名称:refarm-site,代码行数:32,代码来源:test_admin_models.py


注:本文中的django.http.request.HttpRequest._messages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。