Skip to content

Development Environment

ConnorCarlson edited this page Jan 28, 2021 · 20 revisions

If you're using Windows, do this first.

To bootstrap dev env

git clone https://github.com/pnsn/squacapi.git

The app uses docker-compose to manage the app and db environments. See ./docker-compose.yml for container specifics.

Run docker-compose to build out the containers and run migrations

docker-compose up

Run bootstrap_db to bootstrap data for a dev env. This will stub out all data in the /fixtures/fixtures_all.yml as well as make days=n number of days of hourly measurements for a small set of channels and metrics.

docker-compose run --rm app sh -c "python manage.py bootstrap_db days=7"

or

./mg.sh 'bootstrap_db --days=7'

The script mg.sh is a helper script for docker-compose commands and is of the form:

docker-compose run --rm app sh -c "python manage.py $1"

The test data has several users, whose email name maps to a role, and all share the same password.

see /fixtures/fixtures_all.json for a full list

Running tests

To run the entire test suite with flake8 lining

./mg.sh 'test && flake8'

To run all tests in an app:

./mg.sh 'test app_name && flake8'

To run file_name.py in app_name.test (note you don't need the .py in file_name)

./mg.sh "test app_name.tests.file_name && flake8"

To rebuild app

docker-compose build

To rebuild db (drop existing db and rerun migrations)

docker rm squacapi_db

docker volume prune

docker-compose up --rebuild

Postgres psql

to run the psql env locally

./db.sh

Creating a Windows environment

The best way to run this environment on windows is to use the Windows Linux Subsystem.

After following those directions to set it up, you will then need to install docker as you would in a ubuntu machine. You may also need to install python3 as you would on a Linux machine.

You may now edit code on WSL2 using the VS Code installed on your windows machine by following these instructions.

After following these steps you may proceed to follow the rest of this guide.

Clone this wiki locally