Mercurial > p > roundup > code
diff test/test_sqlite.py @ 6638:e1588ae185dc issue2550923_computed_property
merge from default branch. Fix travis.ci so CI builds don't error out
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 21 Apr 2022 16:54:17 -0400 |
| parents | 0d99ae7c8de6 |
| children | 044dcf3608a2 |
line wrap: on
line diff
--- a/test/test_sqlite.py Fri Oct 08 00:37:16 2021 -0400 +++ b/test/test_sqlite.py Thu Apr 21 16:54:17 2022 -0400 @@ -16,6 +16,8 @@ # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. import unittest, os, shutil, time +import sqlite3 as sqlite + from roundup.backends import get_backend, have_backend from .db_test_base import DBTest, ROTest, SchemaTest, ClassicInitTest, config @@ -32,8 +34,43 @@ class sqliteDBTest(sqliteOpener, DBTest, unittest.TestCase): - pass + + def testUpgrade_6_to_7(self): + + # load the database + self.db.issue.create(title="flebble frooz") + self.db.commit() + + if self.db.database_schema['version'] != 7: + self.skipTest("This test only runs for database version 7") + + self.db.database_schema['version'] = 6 + + # dropping _fts + # select * from _fts + # it should fail. + # run post-init + # same select should succeed (with no rows returned) + self.db.sql("drop table __fts") + + with self.assertRaises(sqlite.OperationalError) as ctx: + self.db.sql("select * from __fts") + + self.assertIn("no such table: __fts", ctx.exception.args[0]) + + if hasattr(self, "downgrade_only"): + return + + # test upgrade adding __fts table + self.db.post_init() + + # select should now work. + self.db.sql("select * from __fts") + + # we should be at the current db version + self.assertEqual(self.db.database_schema['version'], + self.db.current_db_version) class sqliteROTest(sqliteOpener, ROTest, unittest.TestCase): pass
