Tests are written and executed using pytest.
If you don’t have Nix and lorri or can’t use an existing PostgreSQL server, have a look at Development Environment.
Steps 1 and 2 can be skipped when you already followed Development Quick Start. Steps 3 and 4 set up a separate database for running the tests.
Clone the repository and enter nix shell in the project root folder to open a shell which is your test environment:
git clone https://github.com/edemocracy/ekklesia-portal cd ekklesia-portal lorri shell
Compile translations and CSS (look at dodo.py to see what this does):
Make sure that the database connection URL points to an empty + writable database. By default, the tests use the Postgres socket in
/tmpand the database name is
test_ekklesia_portal. You can set the environment variable
EKKLESIA_PORTAL_TEST_DB_URLto customize the database connection.
Initialize the test database:
The tests can be run inside a Nix/lorri shell with the pytest command from the repository root directory.
You can supply a path to run only a part of the test suite, here only for the proposition concept:
This also works for single modules:
Or you can select tests by a part of the name:
pytest -k test_arg
See the Usage and Invocations in the pytest documentation for more info.