diff --git a/tests/functional/openlp_plugins/songs/test_db.py b/tests/functional/openlp_plugins/songs/test_db.py index e37cc58cb..690b89a18 100644 --- a/tests/functional/openlp_plugins/songs/test_db.py +++ b/tests/functional/openlp_plugins/songs/test_db.py @@ -172,7 +172,7 @@ class TestDB(TestCase): # THEN: It should return the name with the type in brackets self.assertEqual("John Doe (Words)", display_name) - def test_upgrade_song_db(self): + def test_upgrade_old_song_db(self): """ Test that we can upgrade an old song db to the current schema """ @@ -188,3 +188,20 @@ class TestDB(TestCase): # Then the song db should have been upgraded to the latest version self.assertEqual(updated_to_version, latest_version, 'The song DB should have been upgrade to the latest version') + + def test_upgrade_invalid_song_db(self): + """ + Test that we can upgrade an invalid song db to the current schema + """ + # GIVEN: A song db with invalid version + invalid_db_path = os.path.join(TEST_RESOURCES_PATH, "songs", 'songs-2.2-invalid.sqlite') + invalid_db_tmp_path = os.path.join(self.tmp_folder, 'songs-2.2-invalid.sqlite') + shutil.copyfile(invalid_db_path, invalid_db_tmp_path) + db_url = 'sqlite:///' + invalid_db_tmp_path + + # WHEN: upgrading the db + updated_to_version, latest_version = upgrade_db(db_url, upgrade) + + # Then the song db should have been upgraded to the latest version without errors + self.assertEqual(updated_to_version, latest_version, + 'The song DB should have been upgrade to the latest version') diff --git a/tests/resources/songs/songs-1.9.7.sqlite b/tests/resources/songs/songs-1.9.7.sqlite old mode 100755 new mode 100644 diff --git a/tests/resources/songs/songs-2.2-invalid.sqlite b/tests/resources/songs/songs-2.2-invalid.sqlite new file mode 100644 index 000000000..0c991d5a3 Binary files /dev/null and b/tests/resources/songs/songs-2.2-invalid.sqlite differ