本文整理匯總了Python中invenio.modules.workflows.models.BibWorkflowObject._update_db方法的典型用法代碼示例。如果您正苦於以下問題:Python BibWorkflowObject._update_db方法的具體用法?Python BibWorkflowObject._update_db怎麽用?Python BibWorkflowObject._update_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類invenio.modules.workflows.models.BibWorkflowObject
的用法示例。
在下文中一共展示了BibWorkflowObject._update_db方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_data_object_created_outside
# 需要導入模塊: from invenio.modules.workflows.models import BibWorkflowObject [as 別名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import _update_db [as 別名]
def test_data_object_created_outside(self):
from invenio.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import start
obj = BibWorkflowObject()
initial_data = {'data': 20}
obj.set_data(initial_data)
obj._update_db()
final_data = {'data': 41}
workflow = start(workflow_name="test_workflow",
data=[obj], module_name="unit_tests")
# Keep id for cleanup after
self.id_workflows.append(workflow.uuid)
# Get parent object of the workflow we just ran
initial_object = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid,
BibWorkflowObject.id_parent == None) # noqa E711
all_objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid)
# There should only be 2 objects (initial, final)
self.assertEqual(all_objects.count(), 2)
self.assertEqual(obj.get_data(), final_data)
self.assertEqual(obj.version, CFG_OBJECT_VERSION.FINAL)
self.assertEqual(obj.id_parent, initial_object[0].id)
self.assertEqual(initial_object[0].get_data(), initial_data)
示例2: test_logging_for_workflow_objects_without_workflow
# 需要導入模塊: from invenio.modules.workflows.models import BibWorkflowObject [as 別名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import _update_db [as 別名]
def test_logging_for_workflow_objects_without_workflow(self):
"""This test run a virtual object out of a workflow for
test purpose, this object will log several things"""
from invenio.modules.workflows.models import (BibWorkflowObject,
BibWorkflowObjectLog)
initial_data = {'data': 20}
obj_init = BibWorkflowObject(id_workflow=11,
version=CFG_OBJECT_VERSION.INITIAL)
obj_init.set_data(initial_data)
obj_init._update_db()
obj_init.save()
obj_init.log.info("I am a test object")
obj_init.log.error("This is an error message")
# FIXME: loglevels are simply overwritten somewhere in Celery
# even if Celery is not being "used".
#
# This means loglevel.DEBUG is NOT working at the moment!
obj_init.log.debug("This is a debug message")
obj_init._update_db()
obj_test = BibWorkflowObjectLog.query.filter(
BibWorkflowObjectLog.id_object == obj_init.id).all()
messages_found = 0
for current_obj in obj_test:
if current_obj.message == "I am a test object" \
and messages_found == 0:
messages_found += 1
elif current_obj.message == "This is an error message" \
and messages_found == 1:
messages_found += 1
elif current_obj.message == "This is a debug message" \
and messages_found == 2:
messages_found += 1
self.assertEqual(messages_found, 2) # FIXME: should be 3 when debug works
示例3: test_workflow_for_running_object
# 需要導入模塊: from invenio.modules.workflows.models import BibWorkflowObject [as 別名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import _update_db [as 別名]
def test_workflow_for_running_object(self):
"""Test starting workflow with running object given"""
from invenio.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import start_by_oids
initial_data = {'data': 20}
obj_init = BibWorkflowObject(id_workflow=11,
version=CFG_OBJECT_VERSION.INITIAL)
obj_init.set_data(initial_data)
obj_init._update_db()
running_data = {'data': 26}
obj_running = BibWorkflowObject(id_workflow=11,
id_parent=obj_init.id,
version=CFG_OBJECT_VERSION.RUNNING)
obj_running.set_data(running_data)
obj_running._update_db()
workflow = start_by_oids('test_workflow',
[obj_running.id], module_name="unit_tests")
final_data = {u'data': 41}
objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid,
BibWorkflowObject.id_parent == None) # noqa E711
all_objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid)
self.assertEqual(all_objects.count(), 2)
# Check the workflow execution
self._check_workflow_execution(objects,
initial_data,
final_data)
# Check copied INITIAL object
self.assertEqual(obj_init.get_data(), objects[0].get_data())
# Check if first object were untuched
self.assertEqual(obj_init.id_workflow, "11")
objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id == obj_running.id)
self.assertEqual(objects.count(), 0)
示例4: test_workflow_for_halted_object
# 需要導入模塊: from invenio.modules.workflows.models import BibWorkflowObject [as 別名]
# 或者: from invenio.modules.workflows.models.BibWorkflowObject import _update_db [as 別名]
def test_workflow_for_halted_object(self):
"""Test starting workflow with halted object given"""
from invenio.modules.workflows.models import BibWorkflowObject
from invenio.modules.workflows.api import start_by_oids
initial_data = {'data': 1}
obj_init = BibWorkflowObject(id_workflow=123,
version=CFG_OBJECT_VERSION.INITIAL)
obj_init.set_data(initial_data)
obj_init._update_db()
halted_data = {'data': 1}
obj_halted = BibWorkflowObject(id_workflow=123,
id_parent=obj_init.id,
version=CFG_OBJECT_VERSION.HALTED)
obj_halted.set_data(halted_data)
obj_halted._update_db()
workflow = start_by_oids('test_workflow',
[obj_halted.id], module_name="unit_tests")
final_data = {'data': 2}
objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid,
BibWorkflowObject.id_parent == None) # noqa E711
all_objects = BibWorkflowObject.query.filter(
BibWorkflowObject.id_workflow == workflow.uuid)
self.assertEqual(all_objects.count(), 2)
# Check the workflow execution
self._check_workflow_execution(objects,
halted_data,
final_data)
# Check copied INITIAL object
self.assertEqual(obj_halted.get_data(), objects[0].get_data())
# Check if first object were untached
self.assertEqual(obj_init.id_workflow, "123")
self.assertEqual(obj_halted.id_workflow, "123")