Esempio n. 1
0
    def testMergeUpdate(self):
        """
        Test merge run with updates
        """

        # Run merge again settings entry date to older date to ensure id is set to merge
        db = sqlite3.connect(Utils.CORD19 + "/merge/articles.v1.sqlite")
        db.execute(
            "UPDATE articles SET entry='2020-01-01' WHERE id='mb0qcd0b'")
        db.commit()
        db.close()

        # Run merge, should merge a single record
        db = Factory.create(Utils.CORD19 + "/merge")

        # Load entry dates
        dates = Execute.entryDates(Utils.CORD19 + "/data",
                                   Utils.CORD19 + "/data/entry-dates.csv")

        # Run merge process
        merge = db.merge(Utils.CORD19 + "/merge/articles.v1.sqlite", dates)
        db.close()

        # Assert record to merge
        self.assertEqual(merge, {"mb0qcd0b"})
Esempio n. 2
0
    def testMergeEmpty(self):
        """
        Test merge run with no updates
        """

        os.makedirs(Utils.CORD19 + "/merge", exist_ok=True)

        # Copy existing articles.sqlite file
        shutil.copyfile(Utils.CORD19 + "/models/articles.sqlite", Utils.CORD19 + "/merge/articles.v1.sqlite")

        db = Factory.create(Utils.CORD19 + "/merge")

        # Load entry dates
        dates = Execute.entryDates(Utils.CORD19 + "/data", Utils.CORD19 + "/data/entry-dates.csv")

        # Run merge process
        merge = db.merge(Utils.CORD19 + "/merge/articles.v1.sqlite", dates)
        db.close()

        # Assert no records to merge
        self.assertFalse(merge)