本文整理汇总了Python中stubo.cache.Cache.get_response方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.get_response方法的具体用法?Python Cache.get_response怎么用?Python Cache.get_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stubo.cache.Cache
的用法示例。
在下文中一共展示了Cache.get_response方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StubCache
# 需要导入模块: from stubo.cache import Cache [as 别名]
# 或者: from stubo.cache.Cache import get_response [as 别名]
class StubCache(StubData):
def __init__(self, payload, scenario, session_name):
StubData.__init__(self, payload, scenario)
self.session_name = session_name
from stubo.cache import Cache
self.cache = Cache(self.hostname)
def id(self):
return "{0} => {1}".format(self.scenario_key(), self.session_name)
def request_index_id(self):
matchers = u"".join([u"".join(x.split()).strip() for x in self.contains_matchers() or []])
return compute_hash(
u"".join(
[
self.scenario_name,
matchers,
self.request_path() or "",
self.request_method(),
self.request_query_args() or "",
]
)
)
def load_from_cache(self, response_ids, delay_policy_name, recorded, system_date, module_info, request_index_key):
self.payload = dict(response=dict(ids=response_ids))
response = self.get_response_from_cache(request_index_key)
self.payload["response"] = response
self.set_recorded(recorded)
if module_info:
self.set_module(module_info)
if delay_policy_name:
self.load_delay_from_cache(delay_policy_name)
def get_response_from_cache(self, request_index_key):
# look up response
return self.cache.get_response(self.scenario_name, self.session_name, self.response_ids(), request_index_key)
def load_delay_from_cache(self, name):
self.set_delay_policy(self.cache.get_delay_policy(name))
def response_ids(self):
return self.response()["ids"]
def delay_policy_name(self):
name = ""
policy = self.delay_policy()
if policy:
name = policy.get("name")
return name