1
0
Fork 0
forked from s3lph/matemat

Better test coverage in database wrapper.

This commit is contained in:
s3lph 2018-08-28 22:35:52 +02:00
parent e29423c32e
commit fd2b0a4e55

View file

@ -103,3 +103,20 @@ class DatabaseTest(unittest.TestCase):
with db.transaction():
with self.assertRaises(RuntimeError):
self.db.close()
def test_use_before_open(self):
with self.assertRaises(RuntimeError):
with self.db.transaction():
pass
with self.assertRaises(RuntimeError):
self.db.close()
with self.assertRaises(RuntimeError):
_ = self.db._user_version
with self.assertRaises(RuntimeError):
self.db._user_version = 42
def test_setup_prevent_downgrade(self):
self.db._sqlite_db = sqlite3.connect(':memory:')
self.db._user_version = 1337
with self.assertRaises(RuntimeError):
self.db._setup()