Example #1
0
    def test_filtering(self):
        """Test filtering functionality."""
        from ..tasks.harvesting import filtering_oai_pmh_identifier
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.models import BibWorkflowObject

        my_test_obj = BibWorkflowObject()
        my_test_obj.set_data("<record><test></test>"
                             "<identifier>identifier1</identifier></record>")
        my_test_obj.save()

        my_test_obj_b = BibWorkflowObject()
        my_test_obj_b.set_data([
            "<record><test></test><identifier>identifier2"
            "</identifier></record>"
        ])
        my_test_obj_b.save()
        engine = start("test_workflow_dummy",
                       my_test_obj,
                       module_name="unit_tests")

        # Initialize these attributes to simulate task running in workflows
        my_test_obj.data = my_test_obj.get_data()
        my_test_obj.extra_data = my_test_obj.get_extra_data()
        my_test_obj_b.data = my_test_obj_b.get_data()
        my_test_obj_b.extra_data = my_test_obj_b.get_extra_data()
        engine.extra_data = engine.get_extra_data()

        # Try to add an identifier
        self.assertTrue(filtering_oai_pmh_identifier(my_test_obj, engine))

        # Update engine with the added identifier
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        # False because it is already added
        self.assertFalse(filtering_oai_pmh_identifier(my_test_obj, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        self.assertTrue(filtering_oai_pmh_identifier(my_test_obj_b, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        # False because it is already added
        self.assertFalse(filtering_oai_pmh_identifier(my_test_obj_b, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()
Example #2
0
    def test_filtering(self):
        """Test filtering functionality."""
        from ..tasks.harvesting import filtering_oai_pmh_identifier
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.models import BibWorkflowObject

        my_test_obj = BibWorkflowObject()
        my_test_obj.set_data("<record><test></test>"
                             "<identifier>identifier1</identifier></record>")
        my_test_obj.save()

        my_test_obj_b = BibWorkflowObject()
        my_test_obj_b.set_data(["<record><test></test><identifier>identifier2"
                                "</identifier></record>"])
        my_test_obj_b.save()
        engine = start("test_workflow_dummy",
                       my_test_obj,
                       module_name="unit_tests")

        # Initialize these attributes to simulate task running in workflows
        my_test_obj.data = my_test_obj.get_data()
        my_test_obj.extra_data = my_test_obj.get_extra_data()
        my_test_obj_b.data = my_test_obj_b.get_data()
        my_test_obj_b.extra_data = my_test_obj_b.get_extra_data()
        engine.extra_data = engine.get_extra_data()

        # Try to add an identifier
        self.assertTrue(filtering_oai_pmh_identifier(my_test_obj, engine))

        # Update engine with the added identifier
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        # False because it is already added
        self.assertFalse(filtering_oai_pmh_identifier(my_test_obj, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        self.assertTrue(filtering_oai_pmh_identifier(my_test_obj_b, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()

        # False because it is already added
        self.assertFalse(filtering_oai_pmh_identifier(my_test_obj_b, engine))
        engine.set_extra_data(engine.extra_data)
        engine.extra_data = engine.get_extra_data()
Example #3
0
    def test_init_harvesting(self):
        """Test harvesting."""
        from ..tasks.harvesting import init_harvesting
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.models import BibWorkflowObject

        my_test_obj = BibWorkflowObject()
        my_test_obj.set_data([2])
        my_test_obj.save()
        engine = start("test_workflow_dummy", my_test_obj, module_name="unit_tests")
        my_test_obj.data = my_test_obj.get_data()
        my_test_obj.extra_data = my_test_obj.get_extra_data()
        engine.set_extra_data_params(options={"test": True})
        engine.extra_data = engine.get_extra_data()
        init_harvesting(my_test_obj, engine)
        self.assertTrue(engine.get_extra_data()["options"]["test"])
Example #4
0
    def test_init_harvesting(self):
        """Test harvesting."""
        from ..tasks.harvesting import init_harvesting
        from invenio.modules.workflows.api import start
        from invenio.modules.workflows.models import BibWorkflowObject

        my_test_obj = BibWorkflowObject()
        my_test_obj.set_data([2])
        my_test_obj.save()
        engine = start("test_workflow_dummy",
                       my_test_obj,
                       module_name="unit_tests")
        my_test_obj.data = my_test_obj.get_data()
        my_test_obj.extra_data = my_test_obj.get_extra_data()
        engine.set_extra_data_params(options={'test': True})
        engine.extra_data = engine.get_extra_data()
        init_harvesting(my_test_obj, engine)
        self.assertTrue(engine.get_extra_data()["options"]["test"])