Update test to verify issue #89

This commit is contained in:
Itai Shirav 2018-12-14 08:29:08 +02:00
parent 3620b5889d
commit 5c78c315ee
2 changed files with 10 additions and 5 deletions

View File

@ -93,7 +93,7 @@ class Database(object):
self.readonly = False
self.timeout = timeout
self.settings = {}
self.db_exists = False
self.db_exists = False # this is required before running _is_existing_database
self.db_exists = self._is_existing_database()
if readonly:
if not self.db_exists:

View File

@ -151,10 +151,15 @@ class DatabaseTestCase(TestCaseWithData):
exc = cm.exception
self.assertEqual(exc.code, 81)
self.assertEqual(exc.message, "Database db_not_here doesn't exist")
# Now create the database - should succeed
db.create_database()
db.create_table(Person)
db.drop_database()
# Create and delete the db twice, to ensure db_exists gets updated
for i in range(2):
# Now create the database - should succeed
db.create_database()
self.assertTrue(db.db_exists)
db.create_table(Person)
# Drop the database
db.drop_database()
self.assertFalse(db.db_exists)
def test_preexisting_db(self):
db = Database(self.database.db_name, autocreate=False)