REST API responsible for managing partners
- Create virtualenv:
virtualenv drink_partner -p python3
- Install dependencies using
pip
make requirements-dev
-
Install docker or download mongodb
-
Run docker-compose for project dependencies:
docker-compose up
- To run all suite tests:
make test
- To execute specific tests:
make test-matching Q=[test_name_or_test_class_name]
- To execute test coverage:
make test-coverage
- Run service dependencies:
docker compose-up
- Run application:
make run
-
Execute steps
Running application
above -
Access doc endpoint:
127.0.0.1/docs/
- Set token by clicking in
Authorize
button and adding tokentest
-
Clone repository
-
Install Heroku
-
Configure account for heroku. If you already have one just login
heroku login
To create app in your Heroku account:
heroku create app drink_partners
heroku config:set GUNICORN_WORKERS=5 --app drink-partners
heroku config:set PORT=443 --app drink-partners
heroku config:set SIMPLE_SETTINGS=drink_partners.settings.production --app drink-partners
heroku config:set MONGODB_URI=mongodb://<address-mongodb> ---app drink-partners
heroku config:set MOTOR_DB=<database-name> ---app drink-partners
heroku config:set APP_TOKEN=<app-for-token-usage> ---app drink-partners
If you do not have a MongoDB server available, you could the service using Add-ons
from Heroku.
- Access you personal account in
https://id.heroku.com/login
- Filter for the app name you have created (e.g:
drink-partners
) - Click on Menu
Resources
- In
Add-ons
, search formongodb
and click onmLab MongoDB
- It will automatically configure your mongodb for application
In this case, it will generate MONGODB_URI
env var automatically. You can check use command heroku config
as below:
heroku config
GUNICORN_WORKERS: 1
MONGODB_URI: mongodb://heroku_123:some_password@ds059215.mlab.com:59215/heroku_0dmrmq8z
The URI has the following pattern:
mongodb://<user>:<password>@<mongodb_address>/<database_name>
If you do so, you will need to set env var MOTOR_DB
with the content from database name. In this example, database name is heroku_0dmrmq8z
.
heroku config:set MOTOR_DB=heroku_0dmrmq8z ---app drink-partners
You also need to reset MONGODB_URI
with ?retryWrites=false
at the end of the connection string
heroku config:set MONGODB_URI="mongodb://heroku_123:some_password@ds059215.mlab.com:59215/heroku_0dmrmq8z?retryWrites=false"
Access MongoDB and connect to database configured and execute commands in doc/mongodb_indexes.md
Deploy your application to heroku with command:
git push heroku master
heroku logs