forked from s3lph/matemat
Better test coverage in database wrapper.
This commit is contained in:
parent
e29423c32e
commit
fd2b0a4e55
1 changed files with 17 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue