本文整理汇总了Python中mock.mock.MagicMock.get_header方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.get_header方法的具体用法?Python MagicMock.get_header怎么用?Python MagicMock.get_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.get_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rss
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import get_header [as 别名]
def test_rss(container_node, other_container_node, content_node, collections, home_root, guest_user, root):
everybody_rule = get_or_add_everybody_rule()
root.children.append(collections)
collections.access_rule_assocs.append(NodeToAccessRule(ruletype=u"read", rule=everybody_rule))
collections.container_children.append(container_node)
container_node.container_children.append(other_container_node)
other_container_node.content_children.append(content_node)
struct = {"nodelist": [other_container_node, content_node], "build_response_start": time.time()}
params = {}
req = MagicMock()
req.get_header = lambda x: "localhost:8081"
req.fullpath = ""
req.query = ""
res = struct2rss(req, "", params, None, struct=struct)
print res
# TODO: find some way to check XML content properly
assert res.startswith("""<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
<channel>""")
assert "document/testschema" in res
assert "http://localhost:8081/node?id=" in res
示例2: xml_fixture
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import get_header [as 别名]
def xml_fixture(parent_node, content_node):
global mock
parent_node["testvalue"] = "1001"
content_node["testvalue"] = "1002"
struct = {"nodelist": [parent_node, content_node],
"build_response_start": time.time(),
"status": "ok",
"dataready": "0.1",
"retrievaldate": datetime.datetime.now().isoformat(),
"sortfield": "sortfield",
"sortdirection": "up",
"timetable": [],
"result_shortlist": []}
params = {}
if not mock:
req = MagicMock()
mock = req
else:
req = mock
req.get_header = lambda x: "localhost:8081"
req.fullpath = ""
req.query = ""
MetadatatypeFactory(name=u"directory")
MetadatatypeFactory(name=u"testschema")
return struct, req, params