API for BPM Projects
Follow the following instructions to get the project ready to use ASAP:
Be sure you have installed in your system
- Python version 3 in your path. It will install automatically pip as well.
- A virtual environment, namely venv.
Go to the directory of the project
-
Install the virtual environment
virtualenv env source env/bin/activate
-
Install the dependencies using the
requirements.txt
For development
pip install -r requirements/dev.txt
For production
pip install -r requirements.txt
There are dependencies for multiple environments:
-
dev
: Used for development. Tries to simplify complexity in sake of a better understanding of the bussiness logic. -
prod
: Likedev
but for production. -
azure-dev
: Used for development using real Azure resources, i.e. it connects remotely to try real PaaS provided by Azure, e.g. a Mongo database in Azure Cosmos DB. It requires:- A MongoDB database installed and running in the local pc
-
azure-prod
: Alike toazure-dev
but for production
Its highly recommended a virtual environment be created for each configuration.
Run the project using
-
For using Flask's development capabilities as the autoloading set this
FLASK_ENV
environment variable todevelopment
, i.e.export FLASK_ENV=development
-
Run the app with one of the following commands:
python3 -m bpm_projects_api
thanks to the__main__.py
gunicorn -b 0.0.0.0:8000 run:app
What it basically does is to set the FLASK_APP
env variable to the main package and run the app using Flask
.
If you are using an IDE like PyCharm the process is way easier because they support configurations for running Flask projects.
- The main page provides a nice client to test the API and even for you to provide your JWT: Click the lock.
- To get a token, go to
/login
and authenticate with any username and passwordsecret
(Just for now of course). - In the main page you will also find a Models section for you to check the schema of the managed resources: projects and its metadata.
- The swagger schema can be found in
/swagger.json
. You can even generate client code for this API thanks to this file.
The use of an IDE is highly recommended, namely PyCharm.
Have in consideration that the token will expire each minute.
To execute all tests just run
python3 -m pytest -v
The -v
shows which tests failed or succeeded.
Have in count that you can also debug each test (test_*
files) with the help of an IDE like PyCharm.
To check the coverage of the tests execute
coverage run -m pytest -v
To get a report table
coverage report
To get a full report in html
coverage html
Then check in the htmlcov/index.html to see it
To show all possible commands to use in the project please execute:
python cli.py
You can generate Postman collections with the CLI using
python cli.py gen_postman_collection
It will print the collection json code to the console. If you want to write the result in a file use the -f
or
--filename
option
python cli.py gen_postman_collection -f ~/bpm-projects-collection.json
Afterwards you can import this collection into Postman and use it instead of the main web app to test this api

- Python version 3 as backend programming language
- Flask as backend framework
- Flask RestPlus for building Restful APIs
- Swagger for documentation and standardization
Copyright 2018 ioet Inc. All Rights Reserved.