예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    def test_restart_workflow(self):
        """Tests restarting workflow for given workflow id"""
        from invenio.modules.workflows.models import BibWorkflowObject
        from invenio.modules.workflows.api import (start, start_by_wid)

        initial_data = {'data': 1}

        # testing restarting from previous task
        init_workflow = start(workflow_name="test_workflow",
                              data=[initial_data],
                              module_name="unit_tests")
        init_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == init_workflow.uuid)

        restarted_workflow = start_by_wid(wid=init_workflow.uuid,
                                          module_name="unit_tests")
        restarted_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == restarted_workflow.uuid)

        self.assertEqual(restarted_objects.count(), 1)

        self.assertEqual(restarted_objects[0].version, init_objects[1].version)
        self.assertEqual(restarted_objects[0].id_parent, init_objects[0].id)
        self.assertEqual(restarted_objects[0].get_data(),
                         init_objects[1].get_data())
예제 #4
0
    def test_restart_workflow(self):
        """Test restarting workflow for given workflow id."""
        from invenio.modules.workflows.models import (BibWorkflowObject,
                                                      ObjectVersion)
        from invenio.modules.workflows.api import start, start_by_wid

        initial_data = 1

        init_workflow = start(workflow_name="test_workflow",
                              data=[initial_data],
                              module_name="unit_tests")

        init_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == init_workflow.uuid
        ).order_by(BibWorkflowObject.id).all()
        self.assertEqual(2, len(init_objects))
        restarted_workflow = start_by_wid(wid=init_workflow.uuid,
                                          module_name="unit_tests")

        # We expect the same workflow to be re-started
        self.assertTrue(init_workflow.uuid == restarted_workflow.uuid)

        restarted_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == restarted_workflow.uuid
        ).order_by(BibWorkflowObject.id).all()
        # This time we should only have one more initial object
        self.assertEqual(2, len(restarted_objects))

        # Last object will be INITIAL
        self.assertEqual(ObjectVersion.INITIAL, restarted_objects[1].version)

        self.assertEqual(restarted_objects[1].id_parent,
                         restarted_objects[0].id)
예제 #5
0
    def test_restart_workflow(self):
        """Test restarting workflow for given workflow id."""
        from invenio.modules.workflows.models import (BibWorkflowObject,
                                                      ObjectVersion)
        from invenio.modules.workflows.api import start, start_by_wid

        initial_data = 1

        init_workflow = start(workflow_name="test_workflow",
                              data=[initial_data],
                              module_name="unit_tests")

        init_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == init_workflow.uuid
        ).order_by(BibWorkflowObject.id).all()
        self.assertEqual(2, len(init_objects))
        restarted_workflow = start_by_wid(wid=init_workflow.uuid,
                                          module_name="unit_tests")

        # We expect the same workflow to be re-started
        self.assertTrue(init_workflow.uuid == restarted_workflow.uuid)

        restarted_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == restarted_workflow.uuid
        ).order_by(BibWorkflowObject.id).all()
        # This time we should only have one more initial object
        self.assertEqual(2, len(restarted_objects))

        # Last object will be INITIAL
        self.assertEqual(ObjectVersion.INITIAL, restarted_objects[1].version)

        self.assertEqual(restarted_objects[1].id_parent,
                         restarted_objects[0].id)
예제 #6
0
    def test_restart_workflow(self):
        """Tests restarting workflow for given workflow id"""
        from invenio.modules.workflows.models import BibWorkflowObject
        from invenio.modules.workflows.api import (start, start_by_wid)

        initial_data = {'data': 1}

        # testing restarting from previous task
        init_workflow = start(workflow_name="test_workflow",
                              data=[initial_data], module_name="unit_tests")
        init_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == init_workflow.uuid)

        restarted_workflow = start_by_wid(wid=init_workflow.uuid, module_name="unit_tests")
        restarted_objects = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == restarted_workflow.uuid)

        self.assertEqual(restarted_objects.count(), 1)

        self.assertEqual(restarted_objects[0].version, init_objects[1].version)
        self.assertEqual(restarted_objects[0].id_parent, init_objects[0].id)
        self.assertEqual(restarted_objects[0].get_data(), init_objects[1].get_data())
예제 #7
0
    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"])
예제 #8
0
    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"])