本文整理汇总了Python中stubo.model.db.Scenario.insert_stub方法的典型用法代码示例。如果您正苦于以下问题:Python Scenario.insert_stub方法的具体用法?Python Scenario.insert_stub怎么用?Python Scenario.insert_stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stubo.model.db.Scenario
的用法示例。
在下文中一共展示了Scenario.insert_stub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exception_response
# 需要导入模块: from stubo.model.db import Scenario [as 别名]
# 或者: from stubo.model.db.Scenario import insert_stub [as 别名]
trace=trace,
url_args=url_args)
if source_stub != stub:
trace.diff('stub was transformed', source_stub.payload,
stub.payload)
trace.info('stub was transformed into', stub.payload)
scenario_name = session['scenario']
handler.track.scenario = scenario_name.partition(':')[2]
session_status = session['status']
if session_status != 'record':
raise exception_response(400, title='Scenario not in record '
'mode - {0} in {1} mode.'.format(scenario_name, session_status))
doc = dict(scenario=scenario_name, stub=stub)
scenario_col = Scenario()
result = scenario_col.insert_stub(doc, stateful)
response = {
'version' : version
}
response['data'] = {'message' : result}
return response
def calculate_delay(policy):
delay = 0
delay_type = policy.get('delay_type')
if delay_type == 'fixed':
delay = policy['milliseconds']
elif delay_type == 'normalvariate':
# Calculate from the normal distribution, but set minimum at zero
delay = max(0.0, random.normalvariate(int(policy['mean']),
int(policy['stddev'])))