本文整理汇总了Python中SpiffWorkflow.Workflow.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.deserialize方法的具体用法?Python Workflow.deserialize怎么用?Python Workflow.deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpiffWorkflow.Workflow
的用法示例。
在下文中一共展示了Workflow.deserialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSerializeWorkflow
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import deserialize [as 别名]
def testSerializeWorkflow(self, path_file=None, data=None):
if self.serializer is None:
return
if path_file is None:
path_file = os.path.join(data_dir, 'spiff', 'workflow1.path')
path = open(path_file).read()
elif os.path.exists(path_file):
path = open(path_file).read()
else:
path = None
# run a workflow fresh from the spec to completion, see if it
# serialises and deserialises correctly.
workflow_without_save = run_workflow(self, self.wf_spec, path, data)
try:
serialized1 = workflow_without_save.serialize(self.serializer)
restored_wf = Workflow.deserialize(self.serializer, serialized1)
serialized2 = restored_wf.serialize(self.serializer)
except TaskNotSupportedError as e:
return
else:
self.assert_(isinstance(serialized1, self.serial_type))
self.assert_(isinstance(serialized2, self.serial_type))
self.compareSerialization(serialized1, serialized2)
# try an freshly started workflow, see if it serialises and
# deserialiases correctly. (no longer catch for exceptions: if they
# were going to happen they should have happened already.)
workflow = Workflow(self.wf_spec)
serialized1 = workflow.serialize(self.serializer)
restored_wf = Workflow.deserialize(self.serializer, serialized1)
serialized2 = restored_wf.serialize(self.serializer)
self.assert_(isinstance(serialized1, self.serial_type))
self.assert_(isinstance(serialized2, self.serial_type))
self.compareSerialization(serialized1, serialized2)
self.assertFalse(restored_wf.is_completed())
# Run it to completion, see if it serialises and deserialises correctly
# also check if the restored and unrestored ones are the same after
# being run through.
workflow_unrestored = run_workflow(self, self.wf_spec, path, data, workflow=workflow)
workflow_restored = run_workflow(self, self.wf_spec, path, data, workflow=restored_wf)
serialized1 = workflow_restored.serialize(self.serializer)
restored_wf = Workflow.deserialize(self.serializer, serialized1)
serialized2 = restored_wf.serialize(self.serializer)
self.assert_(isinstance(serialized1, self.serial_type))
self.assert_(isinstance(serialized2, self.serial_type))
self.compareSerialization(serialized1, serialized2)
serialized_crosscheck = workflow_unrestored.serialize(self.serializer)
self.assert_(isinstance(serialized_crosscheck, self.serial_type))
# compare the restored and unrestored completed ones. Because they ran
# separately, exclude the last_state_change time. Because you can have
# dynamically created tasks, don't compare (uu)ids.
self.compareSerialization(serialized_crosscheck, serialized2,
exclude_dynamic=True)
示例2: testDictionarySerializer
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import deserialize [as 别名]
def testDictionarySerializer(self):
"""
Tests the SelectivePickler serializer for persisting Workflows and Tasks.
"""
old_workflow = self.workflow
serializer = DictionarySerializer()
serialized_workflow = old_workflow.serialize(serializer)
serializer = DictionarySerializer()
new_workflow = Workflow.deserialize(serializer, serialized_workflow)
before = old_workflow.get_dump()
after = new_workflow.get_dump()
self.assert_(before == after, 'Before:\n' + before + '\n' \
+ 'After:\n' + after + '\n')
示例3: testDeserialization
# 需要导入模块: from SpiffWorkflow import Workflow [as 别名]
# 或者: from SpiffWorkflow.Workflow import deserialize [as 别名]
def testDeserialization(self):
"""
Tests the that deserialized workflow can be completed.
"""
old_workflow = self.workflow
old_workflow.complete_next()
self.assertEquals('task_a2', old_workflow.last_task.get_name())
serializer = DictionarySerializer()
serialized_workflow = old_workflow.serialize(serializer)
serializer = DictionarySerializer()
new_workflow = Workflow.deserialize(serializer, serialized_workflow)
self.assertEquals('task_a2', old_workflow.last_task.get_name())
new_workflow.complete_all()
self.assertEquals('task_a2', old_workflow.last_task.get_name())