See the CPHO slack channel's link bar for the dev app's URL
Note: run all this in the repo's root directory
-
install python3.10
-
install postgres instructions here
-
clone repo
-
create a virtual environment in repo root (python -m venv venv)
-
activate virtual environment (source venv/Scripts/activate on windows, venv/bin/activate on *nix)
-
install dependencies (
pip install -r server/requirements.txt -r server/requirements_dev.txt) -
(if applicable) Start the db server:
pg_ctl -D ~/pg/data/ -l logfile start -
setting postgres:
./server/dev-db-init.sh -
seed the DB
-
python ./manage.py migrate python ./manage.py loaddata cpho/fixtures/dimension_lookups.yaml python ./manage.py loaddata cpho/fixtures/periods.yaml python -m manage seed_countries --mode reset --yes python ./manage.py runscript cpho.scripts.dev
-
-
python manage.py runserver
resetting dev db:
dropdb -U cpho_db_user cpho_dev_db;
createdb -U cpho_db_user cpho_dev_db;Resetting test db (useful when migrations get in the way of running tests)
dropdb -U cpho_db_user cpho_test_dbIn the case your CI is failing due to formatting issues, you can run the following commands to fix them all.
isort server --settings-path pyproject.tomlblack server/ --config pyproject.tomldjlint --reformat server --configuration pyproject.toml
Note: if you set USE_SQLITE=True in your .env file, you don't need to set any of the DB-related environment variables and the app will use sqlite instead of postgres. This is useful for testing/development, especially on the PHAC workstations. Note that changelogs won't work with sqlite, so those tests will always fail.
To connect to the remote DB from your local machine, download, chmod and ensure the cloud-sql-proxy is in your path, then run source deploy/connect_cloud_sql_proxy.sh. In a different shell, you can now run ./manage.py commands directly against the remote DB. Be careful and make sure you close the script process when you're done.
From the server/ directory run the following
coverage run --source=. ./manage.py test tests/coverage html -ipython -m http.server 1337- visit
http://localhost:1337/htmlcov/and dig into modules to see which individual line coverage