- Generate a new migration
flask db migrate -m "message"- Apply migration to database
flask db upgrade
- After running migrations, setup seed data
flask seed run- Add the roles in this format(Admin, Provider, Patient, User)
- from /user-manager/user_manager
- Install dependencies using Pipenv
1.
pip install pipenv1.pipenv install1.pipenv shell - Run application
1.
python app.py- If you get a path error "No such file or directory for app.py"
- Start app with:
python -m flask runOR include the full path (egpython /Users/laura/workspace/user-manager/user_manager/app.py)
- Create a file called ".env"
- See ".env.example" for the required environment variables
- Ensure your syntax is cleaned up before you commit, install pre-commit
- Global setup:
- Pre-commit needs to be added to your machine's global packages.
- MacOS: Run:
brew install pre-commit - Other operating systems, see pre-commit website.
- Local setup:
1. Pre-commit needs to be added to your local .git directory within each project.
1. Once "pre-commit" is installed globally on your machine, you need to set it up locally for each project.
- From /user-manager run
pre-commit install.
- From /user-manager run
- Pre-commit hooks are linter tests that run each time you attempt to commit. If the tests pass, the commit will be made, otherwise:
1. Black may make syntax changes may be made on your behalf.
- The files that were changes will be taken off of git's "stage" and you will need to add them back. 1. Read the message from "pre-commit" carefully, you may need to manually remove an unused dependency. Once, you have done this, add the file back to git's "stage" and try committing again. 1. Code style has been implemented using Black.
- Black is a PEP 8 compliant opinionated formatter. Black reformats entire files in place. It is not configurable. It doesn't take previous formatting into account.
- Black's opinions
- See configuration files: and Flake8. See configuration files: .isort.cfg, .pre-commit-config.yaml, pyproject.toml and setup.cfg.
- Commit message format:
-
Format:
[STORY ID] COMMIT TITLE - ITEM COMPLETED - ANOTHER ITEM COMPLETED -
Example:
ESSW-66 add endpoint for getting patients - add test coverage to Patients resource - update Patient schema to show nested attributes
- build image (name it something short a sweet with
-tflag)- run
docker build -t um . - note: be sure that you are in the same directory as your Dockerfile (eg user-manager/user_manager)
- run
- run docker image
- run
docker run --env-file=.env -p 5000:5000 um - "um" below refers to the tag we created in the previous step
- run
- Set the env variable mentioned below(For window replace export with set) export TEST_POSTGRES_DB_PORT=5432 export TEST_POSTGRES_DB_USER_KEY=postgres export TEST_POSTGRES_DB_PASSWORD_KEY=Es#12390 export TEST_POSTGRES_DB_HOST=dev-es-db.caneampnjecs.us-west-1.rds.amazonaws.com export TEST_POSTGRES_DB_NAME=test-esumdb export ACCESS_TOKEN_KEY=C718D5FDDEC279567385BE3E52894 export REFRESH_TOKEN_KEY=9EA72AD96C39A87A1AFF153983592 export DEVICE_BASE_URL=http:/fake.com export SECRET_MANAGER_ARN=value export OTP_EXPIRATION_TIME_HOURS=1 export OTP_EXPIRATION_TIME_MINUTES=20 export OTP_LIMIT=1 export OTP_LIMIT_HOURS=1 export OTP_LIMIT_MINUTES=20
- Run command:
- pytest
- To run particular file test case
- pytest <file_path>
- set the env variables
- coverage run -m pytest
- coverage html (Create a html dir -> htmlcov)
- coverage report (Show report in console)