def test_workflows_tasks(self):
        """Test delayed workflows in non delayed one."""
        from invenio_workflows.models import BibWorkflowObject
        from invenio_workflows.api import start

        test_object = BibWorkflowObject()
        test_object.save()
        test_object.set_data(22)
        engine = start("demo_workflow_workflows", [test_object], module_name="unit_tests")
        from invenio_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"])
Example #2
0
    def test_workflow_task_results(self):
        """Test the setting and getting of task results."""
        from invenio_workflows.models import BibWorkflowObject

        test_object = BibWorkflowObject()
        test_object.save()  # Saving is needed to instantiate default values

        test_object.add_task_result("test", {"data": "testing"})
        results = test_object.get_tasks_results()
        self.assertEqual(len(results.get("test")), 1)

        result_item = results.get("test")[0]
        self.assertEqual({"data": "testing"}, result_item.get("result"))
        self.assertEqual("workflows/results/default.html",
                         result_item.get("template"))
        self.assertEqual("test", result_item.get("name"))
    def test_workflow_task_results(self):
        """Test the setting and getting of task results."""
        from invenio_workflows.models import BibWorkflowObject

        test_object = BibWorkflowObject()
        test_object.save()  # Saving is needed to instantiate default values

        test_object.add_task_result("test", {"data": "testing"})
        results = test_object.get_tasks_results()
        self.assertEqual(len(results.get("test")), 1)

        result_item = results.get("test")[0]
        self.assertEqual({"data": "testing"},
                         result_item.get("result"))
        self.assertEqual("workflows/results/default.html",
                         result_item.get("template"))
        self.assertEqual("test",
                         result_item.get("name"))