From 5c78c315ee0c3b028d486a8f3f9fe100bcd9b4ce Mon Sep 17 00:00:00 2001 From: Itai Shirav Date: Fri, 14 Dec 2018 08:29:08 +0200 Subject: [PATCH] Update test to verify issue #89 --- src/infi/clickhouse_orm/database.py | 2 +- tests/test_database.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/infi/clickhouse_orm/database.py b/src/infi/clickhouse_orm/database.py index eefa38e..bccc7ab 100644 --- a/src/infi/clickhouse_orm/database.py +++ b/src/infi/clickhouse_orm/database.py @@ -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: diff --git a/tests/test_database.py b/tests/test_database.py index c603dde..dd8776e 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -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)