Fix how test database settings are passed to management commands for unit tests.

This commit is contained in:
Chris Church
2013-10-16 11:43:18 -04:00
parent 83be067576
commit 508532f57b
3 changed files with 9 additions and 7 deletions

View File

@@ -58,11 +58,12 @@ def prepare_env():
sys.modules['django.utils.six'] = sys.modules['six']
django.utils.six = sys.modules['django.utils.six']
from django.utils import six
# Use the AWX_TEST_DATABASE_NAME environment variable to specify the test
# database name to use when management command is run as an external
# Use the AWX_TEST_DATABASE_* environment variables to specify the test
# database settings to use when management command is run as an external
# program via unit tests.
if os.environ.get('AWX_TEST_DATABASE_NAME', None):
settings.DATABASES['default']['NAME'] = os.environ['AWX_TEST_DATABASE_NAME']
for opt in ('ENGINE', 'NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'):
if os.environ.get('AWX_TEST_DATABASE_%s' % opt, None):
settings.DATABASES['default'][opt] = os.environ['AWX_TEST_DATABASE_%s' % opt]
def manage():
# Prepare the AWX environment.