本文整理汇总了Python中invenio.modules.workflows.models.BibWorkflowObject.get_extra_data方法的典型用法代码示例。如果您正苦于以下问题:Python BibWorkflowObject.get_extra_data方法的具体用法?Python BibWorkflowObject.get_extra_data怎么用?Python BibWorkflowObject.get_extra_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类invenio.modules.workflows.models.BibWorkflowObject
的用法示例。
在下文中一共展示了BibWorkflowObject.get_extra_data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_logic_tasks_continue
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.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.modules.workflows.models import (BibWorkflowObject,
ObjectVersion)
from invenio.modules.workflows.api import (start,
continue_oid)
from invenio.modules.workflows.engine import WorkflowStatus
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
workflow = start('test_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.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_dirty_worker(self):
"""Deep test of celery worker."""
from ..workers.worker_celery import celery_run, celery_restart, celery_continue
from invenio.modules.workflows.utils import BibWorkflowObjectIdContainer
from invenio.modules.workflows.models import BibWorkflowObject, get_default_extra_data
test_objectb = BibWorkflowObject()
test_objectb.set_data(22)
test_objectb.save()
data = BibWorkflowObjectIdContainer(test_objectb).to_dict()
celery_run("test_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("test_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.modules.workflows.worker_result import uuid_to_workflow
engine = uuid_to_workflow(celery_run("test_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"))
from invenio.modules.workflows.engine import WorkflowStatus
self.assertEqual(WorkflowStatus.COMPLETED, engine.status)
示例3: test_filtering
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_filtering(self):
"""Test filtering functionality."""
from ..tasks.harvesting import filtering_oai_pmh_identifier
from invenio.modules.workflows.api import start
from invenio.modules.workflows.models import BibWorkflowObject
my_test_obj = BibWorkflowObject()
my_test_obj.set_data("<record><test></test>"
"<identifier>identifier1</identifier></record>")
my_test_obj.save()
my_test_obj_b = BibWorkflowObject()
my_test_obj_b.set_data(["<record><test></test><identifier>identifier2"
"</identifier></record>"])
my_test_obj_b.save()
engine = start("test_workflow_dummy",
my_test_obj,
module_name="unit_tests")
# Initialize these attributes to simulate task running in workflows
my_test_obj.data = my_test_obj.get_data()
my_test_obj.extra_data = my_test_obj.get_extra_data()
my_test_obj_b.data = my_test_obj_b.get_data()
my_test_obj_b.extra_data = my_test_obj_b.get_extra_data()
engine.extra_data = engine.get_extra_data()
# Try to add an identifier
self.assertTrue(filtering_oai_pmh_identifier(my_test_obj, engine))
# Update engine with the added identifier
engine.set_extra_data(engine.extra_data)
engine.extra_data = engine.get_extra_data()
# False because it is already added
self.assertFalse(filtering_oai_pmh_identifier(my_test_obj, engine))
engine.set_extra_data(engine.extra_data)
engine.extra_data = engine.get_extra_data()
self.assertTrue(filtering_oai_pmh_identifier(my_test_obj_b, engine))
engine.set_extra_data(engine.extra_data)
engine.extra_data = engine.get_extra_data()
# False because it is already added
self.assertFalse(filtering_oai_pmh_identifier(my_test_obj_b, engine))
engine.set_extra_data(engine.extra_data)
engine.extra_data = engine.get_extra_data()
示例4: test_logic_tasks_restart
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.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.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import (start,
start_by_wid)
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
# Initial run
workflow = start('test_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"])
示例5: test_workflow_without_workflow_object_saved
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.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.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import start, start_by_wid
test_object = BibWorkflowObject()
test_object.set_data(0)
test_object.save()
workflow = start('test_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)
示例6: test_workflows_tasks
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_workflows_tasks(self):
"""Test delayed workflows in non delayed one."""
from invenio.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import start
test_object = BibWorkflowObject()
test_object.save()
test_object.set_data(22)
engine = start("test_workflow_workflows", [test_object], module_name="unit_tests")
from invenio.modules.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"])
示例7: test_init_harvesting
# 需要导入模块: from invenio.modules.workflows.models import BibWorkflowObject [as 别名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import get_extra_data [as 别名]
def test_init_harvesting(self):
"""Test harvesting."""
from ..tasks.harvesting import init_harvesting
from invenio.modules.workflows.api import start
from invenio.modules.workflows.models import BibWorkflowObject
my_test_obj = BibWorkflowObject()
my_test_obj.set_data([2])
my_test_obj.save()
engine = start("test_workflow_dummy", my_test_obj, module_name="unit_tests")
my_test_obj.data = my_test_obj.get_data()
my_test_obj.extra_data = my_test_obj.get_extra_data()
engine.set_extra_data_params(options={"test": True})
engine.extra_data = engine.get_extra_data()
init_harvesting(my_test_obj, engine)
self.assertTrue(engine.get_extra_data()["options"]["test"])