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