Postgres Tests
tip
Run through the steps in Setting Up a Dev Environment prior to modifying/testing code.
Preparing to Run Postgres Tests
Test files ending in '_postgres.py' require a postgres database to be accessible.
- Make sure you have Docker running on your machine.
- Open a command prompt and run
docker run -it --rm --name some-postgres -v [path to repository]/database/ddl/base:/docker-entrypoint-initdb.d/ -p 5432:5432 -e POSTGRES_PASSWORD=[your db password here] postgres
- The running database can now be accessed at localhost:5432
- Use the username 'postgres', and your new db password to access the db, and set the password for 'druser'.
docker run -it --rm --network host -e POSTGRES_PASSWORD=[your user password here] postgres psql -h localhost -U postgres`
- Place a file called 'private_config.json' in the postgres' test folder and give it the information for your database.
These values will be injected into your environment variables before the test is run.
{"DATABASE_HOST": "localhost",
"DATABASE_PORT": "5432",
"DATABASE_NAME": "orca",
"DATABASE_USER": "druser",
"DATABASE_PW": "[your user password here]",
"MASTER_USER_PW": "[your db password here]"} - You may now run postgres tests the same way you would unit tests.