Files
notifications-api/pytest.ini
Chris Hill-Scott d36b742e14 Automatically set environment vars before tests
Sometimes you just wanna run some tests directly using the `pytest`
command. But you’re in a new shell, and have forgotten to do
`source environment_test.sh`. The screen fills with red, and your day
just got a little bit worse.

This commit will stop this from ever happening again, by making the
setting environment variables part of running Pytest. It does this with
a plugin called pytest-env[1].

pytest.ini is the standard way of configuring pytest. Creating this file
where it didn’t exist before changes the behaviour of pytest, in that
it will now look for tests in the same directory as the file, rather
than defaulting to the `tests/` directory. So we also have to explicitly
configure pytest[2] to tell it that it should only look in this
directory. Otherwise it gets lost in the weeds of `node_modules`.

This also changes the way that `SQLALCHEMY_DATABASE_URI` is overriden to
the convention used by this plugin.

1. https://github.com/MobileDynasty/pytest-env
2. https://docs.pytest.org/en/latest/customize.html#confval-testpaths

fixup! Remove environment_test.sh
2018-02-14 12:19:12 +00:00

21 lines
638 B
INI

[pytest]
testpaths = tests
env =
D:SQLALCHEMY_DATABASE_URI=postgresql://@localhost/test_notification_api
SECRET_KEY=secret-key
DANGEROUS_SALT=dangerous-salt
NOTIFY_ENVIRONMENT=test
ADMIN_CLIENT_SECRET=dev-notify-secret-key
ADMIN_BASE_URL=http://localhost:6012
FROM_NUMBER=from_number
MMG_URL=https://api.mmg.co.uk/json/api.php
MMG_API_KEY=mmg-secret-key
LOADTESTING_API_KEY=loadtesting
FIRETEXT_API_KEY=Firetext
STATSD_PREFIX=stats-prefix
NOTIFICATION_QUEUE_PREFIX=testing
REDIS_URL=redis://localhost:6379/0
FLASK_APP=application.py
FLASK_DEBUG=1
WERKZEUG_DEBUG_PIN=off