本文整理汇总了Python中SpiffWorkflow.Workflow.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.get_data方法的具体用法?Python Workflow.get_data怎么用?Python Workflow.get_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpiffWorkflow.Workflow
的用法示例。
在下文中一共展示了Workflow.get_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_workflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import get_data [as 别名]
def run_workflow(test, wf_spec, expected_path, expected_data, workflow=None):
# Execute all tasks within the Workflow.
if workflow is None:
taken_path = track_workflow(wf_spec)
workflow = Workflow(wf_spec)
else:
taken_path = track_workflow(workflow.spec)
test.assert_(not workflow.is_completed(), 'Workflow is complete before start')
try:
# We allow the workflow to require a maximum of 5 seconds to
# complete, to allow for testing long running tasks.
for i in range(10):
workflow.complete_all(False)
if workflow.is_completed():
break
time.sleep(0.5)
except:
workflow.task_tree.dump()
raise
#workflow.task_tree.dump()
test.assert_(workflow.is_completed(),
'complete_all() returned, but workflow is not complete\n'
+ workflow.task_tree.get_dump())
# Make sure that there are no waiting tasks left in the tree.
for thetask in Task.Iterator(workflow.task_tree, Task.READY):
workflow.task_tree.dump()
raise Exception('Task with state READY: %s' % thetask.name)
# Check whether the correct route was taken.
if expected_path is not None:
taken_path = '\n'.join(taken_path) + '\n'
error = 'Expected:\n'
error += '%s\n' % expected_path
error += 'but got:\n'
error += '%s\n' % taken_path
test.assert_(taken_path == expected_path, error)
# Check data availibility.
if expected_data is not None:
result = workflow.get_data('data', '')
error = 'Expected:\n'
error += '%s\n' % expected_data
error += 'but got:\n'
error += '%s\n' % result
test.assert_(result == expected_data, error)
return workflow