Skip to content
Permalink
Browse files

Do not hard-code database connection parameters

Rely on libpq defaults instead (overridable via environment)
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Feb 10, 2016
1 parent 942c5e5 commit ab580fbd0e0f238160b2cdee3de47b9a412eb6e5
Showing with 13 additions and 11 deletions.
  1. +12 −10 tests/README.md
  2. +1 −1 tests/src/python/test_provider_postgres.py
@@ -42,17 +42,19 @@ Make sure that you have enabled building of postgres test in CMake.
To test the postgres provider you will need to have a database available to
which the postgres provider can connect. The server will need to have postgis
support enabled.
By default the test uses the following connection options:
dbname='qgis_test'
host=localhost
port=5432
user='postgres'
password='postgres'

By default the test uses the following connection string:

dbname=qgis_test

If this does not match your setup you can set the environment variable
QGIS_PGTEST_DB to the desired connection string.
`QGIS_PGTEST_DB` to the desired connection string, or you can rely
on standard libpq environment variables to tweak host, port user and
password (PGHOST, PGPORT, PGUSER, PGPASSWORD).

Please note that the database needs to be initialized using the sql-script
tests/testdata/provider/testdata.sql
It takes care of activating postgis for the test database and
creates some tables containing test data.

tests/testdata/provider/testdata_pg*.sql

They take care of activating postgis for the test database and
create some tables containing test data.
@@ -33,7 +33,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
cls.dbconn = u'dbname=\'qgis_test\' host=localhost port=5432 user=\'postgres\' password=\'postgres\''
cls.dbconn = u'dbname=\'qgis_test\''
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']
# Create test layers

0 comments on commit ab580fb

Please sign in to comment.
You can’t perform that action at this time.