From d7de98388e6f62dd0425b120e404541d1fce4c32 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 12 Nov 2015 05:17:45 +0000 Subject: [PATCH] Rework configurable 'PW_TEST_DB_xxx' settings There are a number of environment variables that users can set to configure different aspects of their testing environment. Rework these like so: * People use PostgreSQL, so make it as easy as possible for them to develop and test against it. Add a 'PW_TEST_DB_TYPE' setting * Attempt to use defaults for the username and password in settings * Allow the user to configure the database name, if they so wish Signed-off-by: Stephen Finucane --- patchwork/settings/dev.py | 9 ++++++--- requirements-test.txt | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py index e93249c6..0f73a135 100644 --- a/patchwork/settings/dev.py +++ b/patchwork/settings/dev.py @@ -35,12 +35,15 @@ DATABASES = { 'ENGINE': 'django.db.backends.mysql', 'HOST': 'localhost', 'PORT': '', - 'USER': os.environ['PW_TEST_DB_USER'], - 'PASSWORD': os.environ['PW_TEST_DB_PASS'], - 'NAME': 'patchwork', + 'USER': os.getenv('PW_TEST_DB_USER', 'patchwork'), + 'PASSWORD': os.getenv('PW_TEST_DB_PASS', 'password'), + 'NAME': os.getenv('PW_TEST_DB_NAME', 'patchwork'), }, } +if os.getenv('PW_TEST_DB_TYPE', None) == 'postgre': + DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' + if django.VERSION < (1, 7): DATABASES['default']['TEST_CHARSET'] = 'utf8' else: diff --git a/requirements-test.txt b/requirements-test.txt index 035ce131..e6c34ec3 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,3 +1,4 @@ MySQL-python==1.2.5 +psycopg2==2.6.1 python-dateutil==1.5 selenium -- 2.47.3