The dev
script contains a number of useful commands for local development and testing:
new-migration
- Create a new database migration filerun <command>
- Run arbitrary command in the test containerserve
- Run the application, binding to local port 8000shell
- Start an interactive bash shell in the tests containertests
- Run the test suite onceupgrade-requirements
- Generate thepip-tools/*requirements.txt
files frompip-tools/*requirements.in
watch-tests
- Continually watch for file changes and run tests
You can run these commands like so:
./dev tests
If you get an error like this when running the dev
script:
./dev: line 10: conditional binary operator expected
Then you can either:
-
Upgrade your
bash
shell version usinghomebrew
and try again -
Run the script using
zsh
zsh ./dev tests
- Python 3.8 +
pip
python -m venv venv # Create virtual environment
source ./venv/bin/activate # Activate virtual environment
pip install -r requirements.txt # Install requirements
pip install -r pip-tools/dev-requirements.txt # Install requirements
Create an .env
file which minimally contains:
FLASK_APP="broker.app:create_app()"
FLASK_ENV=local-debugging
PGPASSWORD=<your-password>
Export the PostgreSQL password that you set in .env
as an environment variable in your shell so that Docker can set it on the database:
export PGPASSWORD=<your-password>
Then, start up a PostgreSQL service that will be exposed on localhost:5432
, which is what is expected by the test suite configuration:
cd docker
docker-compose up -d # Start up services in docker-compose.yml
The -d
flag is optional. If you omit, then logs from the PostgreSQL container will stream to your terminal, which may be helpful in debugging tests.
Follow the VScode documentation to discover, to run, and to debug the tests in VScode.