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


Python StubRequest.from_fs方法代码示例

本文整理汇总了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"
开发者ID:ric03uecS,项目名称:aspen-python,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:nejstastnejsistene,项目名称:aspen-python,代码行数:9,代码来源:test_dispatcher.py

示例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"
开发者ID:ric03uecS,项目名称:aspen-python,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:rayleyva,项目名称:aspen,代码行数:9,代码来源:test_gauntlet.py

示例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
开发者ID:ArmstrongJ,项目名称:aspen-python,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:jarpineh,项目名称:aspen,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:jarpineh,项目名称:aspen,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:ric03uecS,项目名称:aspen-python,代码行数:9,代码来源:test_negotiated_resource.py

示例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
开发者ID:jarpineh,项目名称:aspen,代码行数:21,代码来源:test_negotiated_resource.py

示例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
开发者ID:ArmstrongJ,项目名称:aspen-python,代码行数:7,代码来源:test_negotiated_resource.py

示例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
开发者ID:ric03uecS,项目名称:aspen-python,代码行数:8,代码来源:test_negotiated_resource.py

示例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
开发者ID:jarpineh,项目名称:aspen,代码行数:8,代码来源:test_gauntlet.py

示例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
开发者ID:jarpineh,项目名称:aspen,代码行数:8,代码来源:test_negotiated_resource.py

示例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
开发者ID:alexcouper,项目名称:aspen,代码行数:8,代码来源:test_dispatcher.py

示例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
开发者ID:alexcouper,项目名称:aspen,代码行数:8,代码来源:test_dispatcher.py


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