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


Python DummyRequest.application_url方法代码示例

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


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

示例1: test_forbidden

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import application_url [as 别名]
    def test_forbidden(self):
        from ptahcrowd.forbidden import Forbidden

        class Context(object):
            """ """

        request = DummyRequest()
        request.url = 'http://example.com'
        request.application_url = 'http://example.com'
        request.root = Context()

        excview = Forbidden(HTTPForbidden(), request)
        excview.update()

        res = request.response

        self.assertIs(excview.__parent__, request.root)
        self.assertEqual(res.status, '302 Found')
        self.assertEqual(
            text_(res.headers['location']),
            'http://example.com/login.html?came_from=http%3A%2F%2Fexample.com')

        excview = Forbidden(HTTPForbidden(), request)
        res = excview()
        self.assertEqual(res.status, '302 Found')
开发者ID:webmaven,项目名称:ptahcrowd,代码行数:27,代码来源:test_forbidden.py

示例2: test_forbidden

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import application_url [as 别名]
 def test_forbidden(self):
     from urllib import quote_plus
     from pyramid.testing import DummyRequest
     from lasco.views.auth import forbidden
     request = DummyRequest()
     request.url = 'http://request.url'
     request.application_url = 'http://application.url'
     response = forbidden(request)
     self.assertEqual(response.status, '303 See Other')
     expected = 'http://application.url/login_form?next=%s' % quote_plus(
         request.url)
     self.assertEqual(response.location, expected)
开发者ID:dbaty,项目名称:Lasco,代码行数:14,代码来源:test_auth.py

示例3: test_forbidden_default_root

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import application_url [as 别名]
    def test_forbidden_default_root(self):
        from ptahcrowd.forbidden import Forbidden
        from pyramid.interfaces import IRootFactory

        class Root(object):
            """ """
            def __init__(self, request):
                self.request = request

        request = DummyRequest()
        request.url = 'http://example.com'
        request.application_url = 'http://example.com'

        self.registry.registerUtility(Root, IRootFactory)

        excview = Forbidden(HTTPForbidden(), request)
        excview.update()

        self.assertIs(excview.__parent__, request.root)
        self.assertIsInstance(request.root, Root)
开发者ID:webmaven,项目名称:ptahcrowd,代码行数:22,代码来源:test_forbidden.py


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