Пример #1
0
    def test_redis_for_halted(self):
        from invenio.modules.workflows.models import BibWorkflowObject
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.utils import set_up_redis
        initial_data = {'data': 1}

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

        obj = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == workflow.uuid,
            BibWorkflowObject.id_parent != None).one()

        rs = set_up_redis()
        entry1 = rs.smembers("holdingpen_sort:publisher:Desy")
        entry2 = rs.smembers("holdingpen_sort:category:lower_than_20")

        self.assertTrue(str(obj.id) in entry1)
        self.assertTrue(str(obj.id) in entry2)
Пример #2
0
    def tearDown(self):
        """ Clean up created objects """
        from invenio.modules.workflows.models import (BibWorkflowObject,
                                                      Workflow,
                                                      BibWorkflowEngineLog,
                                                      BibWorkflowObjectLog)
        from invenio.modules.workflows.utils import get_redis_keys, set_up_redis

        workflows = Workflow.get(Workflow.module_name == "unit_tests").all()
        for workflow in workflows:
            BibWorkflowObject.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid).delete()

            objects = BibWorkflowObjectLog.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid).all()
            for obj in objects:
                db.session.delete(obj)
            db.session.delete(workflow)

            objects = BibWorkflowObjectLog.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid).all()
            for obj in objects:
                BibWorkflowObjectLog.delete(id=obj.id)
            BibWorkflowEngineLog.delete(uuid=workflow.uuid)
        # Deleting dumy object created in tests
        db.session.query(BibWorkflowObject).filter(
            BibWorkflowObject.id_workflow.in_(
                [11, 123, 253])).delete(synchronize_session='fetch')
        Workflow.query.filter(Workflow.module_name == "unit_tests").delete()
        db.session.commit()

        rs = set_up_redis()
        keys = get_redis_keys()
        for key in keys:
            keys2 = get_redis_keys(key)
            for key2 in keys2:
                rs.delete("holdingpen_sort:%s:%s" % (
                    key,
                    key2,
                ))
            rs.delete("holdingpen_sort:%s" % (key, ))
        rs.delete("holdingpen_sort")
Пример #3
0
    def tearDown(self):
        """ Clean up created objects """
        from invenio.modules.workflows.models import (BibWorkflowObject,
                                                      Workflow,
                                                      BibWorkflowEngineLog,
                                                      BibWorkflowObjectLog)
        from invenio.modules.workflows.utils import get_redis_keys, set_up_redis

        workflows = Workflow.get(Workflow.module_name == "unit_tests").all()
        for workflow in workflows:
            BibWorkflowObject.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid
            ).delete()

            objects = BibWorkflowObjectLog.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid
            ).all()
            for obj in objects:
                db.session.delete(obj)
            db.session.delete(workflow)

            objects = BibWorkflowObjectLog.query.filter(
                BibWorkflowObject.id_workflow == workflow.uuid
            ).all()
            for obj in objects:
                BibWorkflowObjectLog.delete(id=obj.id)
            BibWorkflowEngineLog.delete(uuid=workflow.uuid)
        # Deleting dumy object created in tests
        db.session.query(BibWorkflowObject).filter(
            BibWorkflowObject.id_workflow.in_([11, 123, 253])
        ).delete(synchronize_session='fetch')
        Workflow.query.filter(Workflow.module_name == "unit_tests").delete()
        db.session.commit()

        rs = set_up_redis()
        keys = get_redis_keys()
        for key in keys:
            keys2 = get_redis_keys(key)
            for key2 in keys2:
                rs.delete("holdingpen_sort:%s:%s" % (key, key2,))
            rs.delete("holdingpen_sort:%s" % (key,))
        rs.delete("holdingpen_sort")
Пример #4
0
    def test_redis_for_halted(self):
        from invenio.modules.workflows.models import BibWorkflowObject
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.utils import set_up_redis
        initial_data = {'data': 1}

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

        obj = BibWorkflowObject.query.filter(
            BibWorkflowObject.id_workflow == workflow.uuid,
            BibWorkflowObject.id_parent != None).one()

        rs = set_up_redis()
        entry1 = rs.smembers("holdingpen_sort:publisher:Desy")
        entry2 = rs.smembers("holdingpen_sort:category:lower_than_20")

        self.assertTrue(str(obj.id) in entry1)
        self.assertTrue(str(obj.id) in entry2)