summaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/tests/unit/ksfixtures/database.py
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2015-09-01 16:03:26 +0200
committerasteroide <thomas.duval@orange.com>2015-09-01 16:04:53 +0200
commit92fd2dbfb672d7b2b1cdfd5dd5cf89f7716b3e12 (patch)
tree7ba22297042019e7363fa1d4ad26d1c32c5908c6 /keystone-moon/keystone/tests/unit/ksfixtures/database.py
parent26e753254f3e43399cc76e62892908b7742415e8 (diff)
Update Keystone code from official Github repository with branch Master on 09/01/2015.
Change-Id: I0ff6099e6e2580f87f502002a998bbfe12673498
Diffstat (limited to 'keystone-moon/keystone/tests/unit/ksfixtures/database.py')
-rw-r--r--keystone-moon/keystone/tests/unit/ksfixtures/database.py29
1 files changed, 5 insertions, 24 deletions
diff --git a/keystone-moon/keystone/tests/unit/ksfixtures/database.py b/keystone-moon/keystone/tests/unit/ksfixtures/database.py
index 15597539..0012df74 100644
--- a/keystone-moon/keystone/tests/unit/ksfixtures/database.py
+++ b/keystone-moon/keystone/tests/unit/ksfixtures/database.py
@@ -13,15 +13,12 @@
import functools
import os
-import shutil
import fixtures
from oslo_config import cfg
from oslo_db import options as db_options
-from oslo_db.sqlalchemy import migration
from keystone.common import sql
-from keystone.common.sql import migration_helpers
from keystone.tests import unit as tests
@@ -42,23 +39,6 @@ def run_once(f):
return wrapper
-def _setup_database(extensions=None):
- if CONF.database.connection != tests.IN_MEM_DB_CONN_STRING:
- db = tests.dirs.tmp('test.db')
- pristine = tests.dirs.tmp('test.db.pristine')
-
- if os.path.exists(db):
- os.unlink(db)
- if not os.path.exists(pristine):
- migration.db_sync(sql.get_engine(),
- migration_helpers.find_migrate_repo())
- for extension in (extensions or []):
- migration_helpers.sync_database_to_version(extension=extension)
- shutil.copyfile(db, pristine)
- else:
- shutil.copyfile(pristine, db)
-
-
# NOTE(I159): Every execution all the options will be cleared. The method must
# be called at the every fixture initialization.
def initialize_sql_session():
@@ -108,17 +88,18 @@ class Database(fixtures.Fixture):
"""
- def __init__(self, extensions=None):
+ def __init__(self):
super(Database, self).__init__()
- self._extensions = extensions
initialize_sql_session()
_load_sqlalchemy_models()
def setUp(self):
super(Database, self).setUp()
- _setup_database(extensions=self._extensions)
self.engine = sql.get_engine()
- sql.ModelBase.metadata.create_all(bind=self.engine)
self.addCleanup(sql.cleanup)
+ sql.ModelBase.metadata.create_all(bind=self.engine)
self.addCleanup(sql.ModelBase.metadata.drop_all, bind=self.engine)
+
+ def recreate(self):
+ sql.ModelBase.metadata.create_all(bind=self.engine)