From 89afcc3a47b78947a1760a09c7033a9dd7725ec5 Mon Sep 17 00:00:00 2001 From: David Stanek Date: Wed, 16 Apr 2014 13:28:50 +0000 Subject: [PATCH] Fixes for in-code documentation Fixes a couple of issues that slid by on review https://review.openstack.org/85651 Change-Id: I2dd19c6d0af9c7c3148811aeb8299656d1afc788 --- keystone/tests/ksfixtures/database.py | 20 +++++++++++++++----- keystone/tests/test_backend_kvs.py | 4 ++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/keystone/tests/ksfixtures/database.py b/keystone/tests/ksfixtures/database.py index 23341fa7cc..f0d66f860c 100644 --- a/keystone/tests/ksfixtures/database.py +++ b/keystone/tests/ksfixtures/database.py @@ -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( diff --git a/keystone/tests/test_backend_kvs.py b/keystone/tests/test_backend_kvs.py index 1bbde9efd2..5318855f13 100644 --- a/keystone/tests/test_backend_kvs.py +++ b/keystone/tests/test_backend_kvs.py @@ -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()