Merge "Fixes for in-code documentation"

This commit is contained in:
Jenkins 2014-04-22 03:09:53 +00:00 committed by Gerrit Code Review
commit eb8fafe2f8
2 changed files with 17 additions and 7 deletions

View File

@ -29,6 +29,10 @@ CONF = config.CONF
def run_once(f):
"""A decorator to ensure the decorated function is only executed once.
The decorated function cannot expect any arguments.
"""
@functools.wraps(f)
def wrapper():
if not wrapper.already_ran:
@ -69,11 +73,17 @@ def _initialize_sql_session():
def _load_sqlalchemy_models():
"""Find all modules containing SQLAlchemy models and import them.
This will create more consistent, deterministic test runs because the
database schema will be predictable. The schema is created based on the
models already imported. This can change during the course of a test run.
If all models are imported ahead of time then the schema will always be
the same.
This creates more consistent, deterministic test runs because tables
for all core and extension models are always created in the test
database. We ensure this by importing all modules that contain model
definitions.
The database schema during test runs is created using reflection.
Reflection is simply SQLAlchemy taking the model definitions for
all models currently imported and making tables for each of them.
The database schema created during test runs may vary between tests
as more models are imported. Importing all models at the start of
the test run avoids this problem.
"""
keystone_root = os.path.normpath(os.path.join(

View File

@ -26,8 +26,8 @@ from keystone.tests import test_backend
class KvsIdentity(tests.TestCase, test_backend.IdentityTests):
def setUp(self):
# NOTE(dstanek): setup the database for subsystems that do not have a
# KVS backend (like credentials)
# NOTE(dstanek): setup the database for subsystems that only have a
# SQL backend (like credentials)
self.useFixture(database.Database())
super(KvsIdentity, self).setUp()