Message ID | 1447308313-4526-4-git-send-email-stephen.finucane@intel.com |
---|---|
State | Accepted |
Headers | show |
On 12 Nov 06:05, Stephen Finucane wrote: > 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 <stephen.finucane@intel.com> Merged.
diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py index e93249c..0f73a13 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 035ce13..e6c34ec 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
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 <stephen.finucane@intel.com> --- patchwork/settings/dev.py | 9 ++++++--- requirements-test.txt | 1 + 2 files changed, 7 insertions(+), 3 deletions(-)