def test_halt_in_branch(self): """Test halt task when in conditionnal branch.""" from workflow.patterns import IF_ELSE from invenio_workflows.registry import workflows from invenio_workflows.api import start from invenio_workflows.engine import WorkflowStatus from invenio_workflows.models import (BibWorkflowObjectLog, ObjectVersion) def always_true(obj, eng): return True def halt_engine(obj, eng): return eng.halt("Test") class BranchTest(object): workflow = [ IF_ELSE(always_true, [halt_engine], [halt_engine]) ] workflows['branchtest'] = BranchTest data = [set(('somekey', 'somevalue'))] eng = start('branchtest', data, module_name="unit_tests") idx, obj = list(eng.getObjects())[0] self.assertEqual(ObjectVersion.WAITING, obj.version) self.assertEqual(WorkflowStatus.HALTED, eng.status) self.assertEqual(0, BibWorkflowObjectLog.get( id_object=obj.id, log_type=logging.ERROR).count())
def test_halt_in_branch(self): """Test halt task when in conditionnal branch.""" from workflow.patterns import IF_ELSE from invenio_workflows.registry import workflows from invenio_workflows.api import start from invenio_workflows.engine import WorkflowStatus from invenio_workflows.models import (BibWorkflowObjectLog, ObjectVersion) def always_true(obj, eng): return True def halt_engine(obj, eng): return eng.halt("Test") class BranchTest(object): workflow = [IF_ELSE(always_true, [halt_engine], [halt_engine])] workflows['branchtest'] = BranchTest data = [set(('somekey', 'somevalue'))] eng = start('branchtest', data, module_name="unit_tests") idx, obj = list(eng.getObjects())[0] self.assertEqual(ObjectVersion.WAITING, obj.version) self.assertEqual(WorkflowStatus.HALTED, eng.status) self.assertEqual( 0, BibWorkflowObjectLog.get(id_object=obj.id, log_type=logging.ERROR).count())
def test_halt(self): """Test halt task.""" from invenio_workflows.registry import workflows from invenio_workflows.api import start from invenio_workflows.engine import WorkflowStatus from invenio_workflows.models import (BibWorkflowObjectLog, ObjectVersion) def halt_engine(obj, eng): return eng.halt("Test") class HaltTest(object): workflow = [halt_engine] workflows['halttest'] = HaltTest data = [set(('somekey', 'somevalue'))] eng = start('halttest', data, module_name="unit_tests") idx, obj = list(eng.getObjects())[0] self.assertEqual(ObjectVersion.WAITING, obj.version) self.assertEqual(WorkflowStatus.HALTED, eng.status) self.assertEqual( 0, BibWorkflowObjectLog.get(id_object=obj.id, log_type=logging.ERROR).count())
def test_halt(self): """Test halt task.""" from invenio_workflows.registry import workflows from invenio_workflows.api import start from invenio_workflows.engine import WorkflowStatus from invenio_workflows.models import (BibWorkflowObjectLog, ObjectVersion) def halt_engine(obj, eng): return eng.halt("Test") class HaltTest(object): workflow = [halt_engine] workflows['halttest'] = HaltTest data = [set(('somekey', 'somevalue'))] eng = start('halttest', data, module_name="unit_tests") idx, obj = list(eng.getObjects())[0] self.assertEqual(ObjectVersion.WAITING, obj.version) self.assertEqual(WorkflowStatus.HALTED, eng.status) self.assertEqual(0, BibWorkflowObjectLog.get( id_object=obj.id, log_type=logging.ERROR).count())