本文整理汇总了Python中invenio_workflows.models.BibWorkflowObject.get_extra_data方法的典型用法代码示例。如果您正苦于以下问题:Python BibWorkflowObject.get_extra_data方法的具体用法?Python BibWorkflowObject.get_extra_data怎么用?Python BibWorkflowObject.get_extra_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio_workflows.models.BibWorkflowObject
的用法示例。
在下文中一共展示了BibWorkflowObject.get_extra_data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_logic_tasks_continue
# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_logic_tasks_continue(self):
"""Test that the logic tasks work correctly when continuing."""
from invenio_workflows.models import (BibWorkflowObject,
ObjectVersion)
from invenio_workflows.api import (start,
continue_oid)
from invenio_workflows.engine import WorkflowStatus
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
workflow = start('demo_workflow_logic', [test_object],
module_name="unit_tests")
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
workflow = continue_oid(test_object.id)
self.assertEqual(6, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
workflow = continue_oid(test_object.id)
self.assertEqual(9, test_object.get_data())
self.assertEqual("gte9", test_object.get_extra_data()["test"])
workflow = continue_oid(test_object.id)
self.assertEqual(15, test_object.get_data())
self.assertEqual("gte9", test_object.get_extra_data()["test"])
workflow = continue_oid(test_object.id)
self.assertEqual(ObjectVersion.COMPLETED, test_object.version)
self.assertEqual(WorkflowStatus.COMPLETED, workflow.status)
示例2: test_dirty_worker
# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_dirty_worker(self):
"""Deep test of celery worker."""
from invenio_workflows.workers.worker_celery import celery_run, celery_restart, celery_continue
from invenio_workflows.utils import BibWorkflowObjectIdContainer
from invenio_workflows.models import BibWorkflowObject, get_default_extra_data
from invenio_workflows.engine import WorkflowStatus
test_objectb = BibWorkflowObject()
test_objectb.set_data(22)
test_objectb.save()
data = BibWorkflowObjectIdContainer(test_objectb).to_dict()
celery_run("demo_workflow", [data], module_name="unit_tests")
self.assertEqual(40, test_objectb.get_data())
test_object = BibWorkflowObject()
test_object.set_data(22)
test_object.save()
test_objectc = BibWorkflowObject()
test_objectc.set_data(22)
test_objectc.save()
data = [test_object, test_objectc]
for i in range(0, len(data)):
if isinstance(data[i], BibWorkflowObject):
data[i] = BibWorkflowObjectIdContainer(data[i]).to_dict()
celery_run("demo_workflow", data, module_name="unit_tests")
self.assertEqual(40, test_object.get_data())
self.assertEqual(40, test_objectc.get_data())
test_object = BibWorkflowObject()
test_object.save()
test_object.set_data(0)
from invenio_workflows.worker_result import uuid_to_workflow
engine = uuid_to_workflow(celery_run("demo_workflow_logic", [test_object], module_name="unit_tests"))
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
engine._extra_data = get_default_extra_data() # reset iterators
celery_restart(engine.uuid)
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
celery_continue(test_object.id, "continue_next")
self.assertEqual(6, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
celery_continue(test_object.id, "continue_next")
self.assertEqual(9, test_object.get_data())
self.assertEqual("gte9", test_object.get_extra_data()["test"])
celery_continue(test_object.id, "continue_next")
self.assertEqual(15, test_object.get_data())
self.assertEqual("gte9", test_object.get_extra_data()["test"])
engine = uuid_to_workflow(celery_continue(test_object.id, "continue_next", module_name="unit_tests"))
self.assertEqual(WorkflowStatus.COMPLETED, engine.status)
示例3: test_logic_tasks_restart
# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_logic_tasks_restart(self):
"""Test that the logic tasks work correctly when restarted."""
from invenio_workflows.models import BibWorkflowObject
from invenio_workflows.api import (start,
start_by_wid)
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
# Initial run
workflow = start('demo_workflow_logic', [test_object],
module_name="unit_tests")
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
# Reset before re-starting (reset Iterator data)
workflow.reset_extra_data()
workflow = start_by_wid(workflow.uuid)
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
示例4: test_workflows_tasks
# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_workflows_tasks(self):
"""Test delayed workflows in non delayed one."""
from invenio_workflows.models import BibWorkflowObject
from invenio_workflows.api import start
test_object = BibWorkflowObject()
test_object.save()
test_object.set_data(22)
engine = start("demo_workflow_workflows", [test_object], module_name="unit_tests")
from invenio_workflows.engine import WorkflowStatus
self.assertEqual(0, engine.get_extra_data()["_nb_workflow_failed"])
self.assertEqual(WorkflowStatus.COMPLETED, engine.status)
self.assertEqual(0, test_object.get_tasks_results()["review_workflow"][0]["result"]["failed"])
self.assertEqual(4, test_object.get_extra_data()["nbworkflowrunning"])
self.assertEqual(21, engine.get_extra_data()["_nb_workflow_finish"])
示例5: test_workflow_without_workflow_object_saved
# 需要导入模块: from invenio_workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio_workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_workflow_without_workflow_object_saved(self):
"""Test that the logic tasks work correctly."""
from invenio_workflows.models import BibWorkflowObject
from invenio_workflows.api import start, start_by_wid
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
workflow = start(
'demo_workflow_logic',
[test_object],
module_name="unit_tests")
self.assertEqual(5, test_object.get_data())
self.assertEqual("lt9", test_object.get_extra_data()["test"])
start_by_wid(workflow.uuid)
test_object.delete(test_object.id)