本文整理汇总了Python中aspen.testing.StubRequest.from_fs方法的典型用法代码示例。如果您正苦于以下问题:Python StubRequest.from_fs方法的具体用法?Python StubRequest.from_fs怎么用?Python StubRequest.from_fs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aspen.testing.StubRequest
的用法示例。
在下文中一共展示了StubRequest.from_fs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handles_busted_accept
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_handles_busted_accept(mk):
mk(("index.spt", NEGOTIATED_RESOURCE))
request = StubRequest.from_fs("index.spt")
# Set an invalid Accept header so it will return default (text/plain)
request.headers["Accept"] = "text/html;"
actual = get_response(request, Response()).body
assert actual == "Greetings, program!\n"
示例2: test_aspen_favicon_doesnt_get_clobbered_by_virtual_path
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_aspen_favicon_doesnt_get_clobbered_by_virtual_path():
mk('%value.spt')
request = StubRequest.from_fs('/favicon.ico')
dispatcher.dispatch(request)
expected = {}
actual = request.line.uri.path
assert actual == expected, actual
示例3: test_get_response_doesnt_reset_content_type_when_not_negotiating
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_doesnt_reset_content_type_when_not_negotiating(mk):
mk(("index.spt", NEGOTIATED_RESOURCE))
request = StubRequest.from_fs("index.spt")
response = Response()
response.headers["Content-Type"] = "never/mind"
actual = get_response(request, response).headers["Content-Type"]
assert actual == "never/mind"
示例4: test_aspen_favicon_doesnt_get_clobbered_by_virtual_path
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_aspen_favicon_doesnt_get_clobbered_by_virtual_path():
mk('%value')
request = StubRequest.from_fs('/favicon.ico')
gauntlet.run_through(request, gauntlet.not_found)
expected = {}
actual = request.line.uri.path
assert actual == expected, actual
示例5: test_can_override_default_renderer_entirely
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_can_override_default_renderer_entirely():
mk(('.aspen/configure-aspen.py', OVERRIDE_SIMPLATE),
('index.spt', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index.spt')
request.headers['Accept'] = 'text/plain'
actual = get_response(request, Response()).body
assert actual == "glubber", actual
示例6: test_get_response_406_gives_list_of_acceptable_types
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_406_gives_list_of_acceptable_types():
mk(('index', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index')
request.headers['Accept'] = 'cheese/head'
actual = assert_raises(Response, get_response, request, Response()).body
expected ="The following media types are available: text/plain, text/html."
assert actual == expected, actual
示例7: test_get_response_doesnt_reset_content_type_when_not_negotiating
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_doesnt_reset_content_type_when_not_negotiating():
mk(('index', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index')
response = Response()
response.headers['Content-Type'] = 'never/mind'
actual = get_response(request, response).headers['Content-Type']
assert actual == "never/mind", actual
示例8: test_get_response_406_gives_list_of_acceptable_types
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_406_gives_list_of_acceptable_types(mk):
mk(("index.spt", NEGOTIATED_RESOURCE))
request = StubRequest.from_fs("index.spt")
request.headers["Accept"] = "cheese/head"
actual = raises(Response, get_response, request, Response()).value.body
expected = "The following media types are available: text/plain, text/html."
assert actual == expected
示例9: test_can_override_default_renderer_entirely
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_can_override_default_renderer_entirely():
mk(('.aspen/configure-aspen.py', """\
from aspen.renderers import Renderer, Factory
class Glubber(Renderer):
def render_content(self, context):
return "glubber"
class GlubberFactory(Factory):
Renderer = Glubber
website.renderer_factories['glubber'] = GlubberFactory(website)
website.default_renderers_by_media_type.default = 'glubber'
"""), ('index', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index')
request.headers['Accept'] = 'text/plain'
actual = get_response(request, Response()).body
assert actual == "glubber", actual
示例10: test_get_response_sets_content_type_when_it_doesnt_negotiate
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_sets_content_type_when_it_doesnt_negotiate():
mk(('index.spt', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index.spt')
actual = get_response(request, Response()).headers['Content-Type']
assert actual == "text/plain; charset=UTF-8", actual
示例11: test_get_response_raises_406_if_need_be
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_raises_406_if_need_be(mk):
mk(("index.spt", NEGOTIATED_RESOURCE))
request = StubRequest.from_fs("index.spt")
request.headers["Accept"] = "cheese/head"
actual = raises(Response, get_response, request, Response()).value.code
assert actual == 406
示例12: check_indirect_negotiation
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def check_indirect_negotiation(path):
"""Given an urlpath, return a filesystem path per gauntlet.virtual_paths.
"""
request = StubRequest.from_fs(path)
gauntlet.run_through(request, gauntlet.indirect_negotiation)
return request
示例13: test_get_response_sets_content_type_when_it_negotiates
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def test_get_response_sets_content_type_when_it_negotiates():
mk(('index', NEGOTIATED_RESOURCE))
request = StubRequest.from_fs('index')
request.headers['Accept'] = 'text/html'
actual = get_response(request, Response()).headers['Content-Type']
assert actual == "text/html; charset=UTF-8", actual
示例14: check_index
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def check_index(path, *a):
"""Given a uripath, return a filesystem path per dispatcher
"""
request = StubRequest.from_fs(path, *a)
dispatcher.dispatch(request)
return request
示例15: check_indirect_negotiation
# 需要导入模块: from aspen.testing import StubRequest [as 别名]
# 或者: from aspen.testing.StubRequest import from_fs [as 别名]
def check_indirect_negotiation(path):
"""Given an urlpath, return a filesystem path per dispatcher.dispatch
"""
request = StubRequest.from_fs(path)
dispatcher.dispatch(request)
return request