[devtools] add has_cache for postgres (closes #5739624)
devtools stores info about existing dbs in the db handler, but in the
case of postgresql that doesn't take into account the path to the
cluster's datadir. Which means if we run two test modules (in the same
test run), we'll create a "__default_empty_db__" for the first one,
cache its existence, and then when moving on to the other module,
believe the template already exists (but since the datadir depends on
the test module's path, it does not). This patch is a bit of a kludge,
and it would be better to make the cache key include enough data to not
need this, but I'm not sure how to do that.
--- a/devtools/__init__.py Tue Sep 22 14:20:02 2015 +0200
+++ b/devtools/__init__.py Fri Jul 24 09:57:08 2015 +0200
@@ -627,6 +627,11 @@
return backup_name
return None
+ def has_cache(self, db_id):
+ backup_name = self._backup_name(db_id)
+ return (super(PostgresTestDataBaseHandler, self).has_cache(db_id)
+ and backup_name in self.helper.list_databases(self.cursor))
+
def init_test_database(self):
"""initialize a fresh postgresql database used for testing purpose"""
from cubicweb.server import init_repository