From 80a8434458964c75d399613fa2982947a21e23a7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 25 Nov 2014 15:11:18 +0100 Subject: [PATCH] Added one more test for song db upgrade --- .../openlp_plugins/songs/test_db.py | 19 +++++++++++++++++- tests/resources/songs/songs-1.9.7.sqlite | Bin .../resources/songs/songs-2.2-invalid.sqlite | Bin 0 -> 35840 bytes 3 files changed, 18 insertions(+), 1 deletion(-) mode change 100755 => 100644 tests/resources/songs/songs-1.9.7.sqlite create mode 100644 tests/resources/songs/songs-2.2-invalid.sqlite 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 0000000000000000000000000000000000000000..0c991d5a3245940e1cd6050098ac57b2713feb0d GIT binary patch literal 35840 zcmeHQ-*4N-9p{O*6f1Spq|G?T^?H^O*e>M6a^j|`9XE=jBw8K2bCjh)Pzbbive;0h zMp9AKm)2ef49LTDa(9KOW$3 zxFG_FK))e?6zbbMsur)Jq$Wp&3i_z`sv z@%#S(b~vhp2<#F8@%=BIm-y@d+J3W0j!9&4__u7BZ_@MwEuEIq74?11*rZo2wZInN zykF7jJ!aXOXyvLT#TRW8u4pz(K(oZsqTaByg1xlJ ziy3tqRdyk9FF|#6gXtF%DQGc%XZdnEm%bBVIZn%Fo!WKA9O{%AwauDQjOWVW+qBht ztVmT_x0q8XQ(e2uXoW4rv(z*SjMi0~>Za`^=|;_=22fEe;1-3;lkrx#LEIYK)pk=07aBk8P93v|O@kwJHeYK>M;;vuKu4SgtQISVm6>y27IZiTTCrBXu;&ra)q^kz8iuV zC=6YrmN*EYK}ofI`qnjFr#evKjmki07bu?%2+Zh;X%#^r8&EPUnhpKFX_^3&2{e=O zYammdx8SgwRS<<0YM=xF3wFTSLxo+|m=5*=DppO)0Sg8M<7sXrV68w}*Fb(|6#13A z5OLlo;%x>H*2~NQ{XrJD>p7>A&g?Rbau4dNh>ROJj z-dtHp()bXkkvCMZyq~Anm#?MQr{?D8rvpv+T-2(4?X16&Ph|NvW$0t3@!{=p;tbwi z&t6Zj-==S6Zqq5PI31s^lbA9xLbkF(700Z?yyw100t&cgJ!B7votk^yFIgDlt+7Z< z86PLxgMzaVe#12H+U+AbAVItQdrMKR!8~f0nbks&3mOj0);T$*jE<7+jF3;QIc3wb zy^n!_WL{wpvBVr0?Aaz~UA3L?nxbY`b+r+!>@bMVE`>4lM`51IGi9D(M!>)SW$9B% z`ZV$v`O9Z-@P9Np7*iC5{CcKkq{2S!XutrtY1%!yzh%0C;Ta!tG)Hfb=8mpab%$Ao z>acugLvFP0T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