- Student 1. Sajjad Ghaeminejad (sghaemin25@student.oulu.fi)
- Student 2. Hieu Nguyen (hieu.nguyen@student.oulu.fi)
- Student 3. Name and email
- Student 4. Name and email
Remember to include all required documentation and HOWTOs, including how to create and populate the database, how to run and test the API, the url to the entrypoint, instructions on how to setup and run the client, instructions on how to setup and run the axiliary service and instructions on how to deploy the api in a production environment
docker compose up --build # docker-compose up --build
# or
docker compose up # docker-compose up- How to set up
python -m pip install virtualenv
python -m virtualenv .venv
source .venv/bin/activate # OR: .venv\Scripts\activate (for Window CLI)
pip install -r requirements.txt
# Deactivate venv
deactivate- How to run
python app.py # OR: flask run- Prettier / format code For example
pylint db_init.py # To check
black db_init.py # To fix auto
# ruff check db_init.py
# ruff check db_init.py --fixThe project includes a functional testing script that we have implemented using pytest. The tests validate:
- Successful operations (GET, POST, PUT, DELETE)
- Proper HTTP status codes
- Correct JSON responses
- Error handling (400, 403, 404, 415)
- Presence of
Locationheader for201 Created
Tests use an in-memory SQLite database and do not require Docker.
From the project root directory:
source .venv/bin/activate
pytest -qIf pytest cannot locate the src package, run:
PYTHONPATH=. pytest -qAll the tests should pass and the outout must be like the following:
15 passed in 0.14sTo see the details of test coverage run:
pytest --cov=src --cov-report=term-missingexpected output:
================================== tests coverage ================================== __ coverage: platform darwin, python 3.9.6-final-0 __
src/init.py 23 0 100% src/api.py 34 3 91% 28, 37, 41 src/extensions.py 2 0 100% src/models.py 114 7 94% 88, 152, 175, 187, 200, 209, 231 src/resources/init.py 0 0 100% src/resources/reading.py 27 3 89% 23, 32, 37 src/resources/readings.py 28 3 89% 22, 34-35 src/resources/shipment.py 31 2 94% 21, 30 src/resources/shipments.py 31 1 97% 23
TOTAL 290 19 93%
- ORM models and functions are defined in
src/models.py. - The repository includes a database dump inside scripts (
postgres/init/initdb.sh) to generate and populate the database. - The
docker-compose.ymlfile defines apostgres-dbcontainer for PostgreSQL (version 15-alpine).
- Run
docker compose up --build.- The
postgres-dbcontainer is created automatically with the empty database namedcoldchain. The database files in this container are persisted/mounted in thepostgres/datadirectory.
- The
- Run
python db_init.pyto create tables and seed data only once - How to verify:
- Run
docker exec -it postgres-db psql -U user -d coldchainto check if the SQL schema is created.- Use the
\dtcommand in thepsqlshell to check for tables.
- Use the
- Run
- No dependencies are needed at this stage except Docker.
- For manual setup, install dependencies, set up PostgreSQL, and run the SQL code in the provided script (
postgres/init/initdb.sh) to initialize and populate the database. However, this project repo does not officially support manual setup.