Exemplo n.º 1
0
    def test_halt_in_branch(self):
        """Test halt task when in conditionnal branch."""
        from workflow.patterns import IF_ELSE
        from invenio.modules.workflows.registry import workflows
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.engine import WorkflowStatus
        from invenio.modules.workflows.models import (BibWorkflowObjectLog,
                                                      ObjectVersion)

        always_true = lambda obj, eng: True
        halt_engine = lambda obj, eng: 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())
Exemplo n.º 2
0
    def test_halt_in_branch(self):
        """Test halt task when in conditionnal branch."""
        from workflow.patterns import IF_ELSE
        from invenio.modules.workflows.registry import workflows
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.engine import WorkflowStatus
        from invenio.modules.workflows.models import (BibWorkflowObjectLog,
                                                      ObjectVersion)

        always_true = lambda obj, eng: True
        halt_engine = lambda obj, eng: 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())
Exemplo n.º 3
0
    def test_halt(self):
        """Test halt task."""
        from invenio.modules.workflows.registry import workflows
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.engine import WorkflowStatus
        from invenio.modules.workflows.models import (BibWorkflowObjectLog,
                                                      ObjectVersion)

        halt_engine = lambda obj, eng: 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())
Exemplo n.º 4
0
    def test_halt(self):
        """Test halt task."""
        from invenio.modules.workflows.registry import workflows
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.engine import WorkflowStatus
        from invenio.modules.workflows.models import (BibWorkflowObjectLog,
                                                      ObjectVersion)

        halt_engine = lambda obj, eng: 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())