本文整理汇总了Python中stubo.model.db.Scenario.insert_pre_stub方法的典型用法代码示例。如果您正苦于以下问题:Python Scenario.insert_pre_stub方法的具体用法?Python Scenario.insert_pre_stub怎么用?Python Scenario.insert_pre_stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stubo.model.db.Scenario
的用法示例。
在下文中一共展示了Scenario.insert_pre_stub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: store_source_recording
# 需要导入模块: from stubo.model.db import Scenario [as 别名]
# 或者: from stubo.model.db.Scenario import insert_pre_stub [as 别名]
def store_source_recording(scenario_name_key, record_session):
host, scenario_name = scenario_name_key.split(':')
# use original put/stub payload logged in tracker
tracker = Tracker()
last_used = tracker.session_last_used(scenario_name_key,
record_session, 'record')
if not last_used:
# empty recordings are currently supported!
log.debug('Unable to find a recording for session={0}, scenario={1}'.format(record_session, scenario_name_key))
return
recording = tracker.get_last_recording(scenario_name, record_session,
last_used['start_time'])
recording = list(recording)
if not recording:
raise exception_response(400,
title="Unable to find a recording for scenario='{0}', record_session='{1}'".format(scenario_name, record_session))
number_of_requests = len(recording)
scenario_db = Scenario()
for nrequest in range(number_of_requests):
track = recording[nrequest]
request_text = track.get('request_text')
if not request_text:
raise exception_response(400, title='Unable to obtain recording details, was full tracking enabled?')
priority = int(track['request_params'].get('priority', nrequest+1))
stub = parse_stub(request_text, scenario_name_key,
track['request_params'])
stub.set_priority(priority)
scenario_db.insert_pre_stub(scenario_name_key, stub)