Example Application Interface using FastAPI framework in Python 3
This example showcases Repository Pattern in Hexagonal Architecture (also known as Clean Architecture). Here we have two Entities - Books and Authors, whose relationships have been exploited to create CRUD endpoint in REST under OpenAPI standard.
-
Create and activate a Virtual Environment for Python 3 in your workspace:
$ python3 -m venv env $ source venv/bin/activate
-
Install all the project dependency using Pip:
$ pip install -r requirements.txt
-
Run the application from command prompt:
$ uvicorn main:app --reload
-
Open
localhost:8000/docs
for API Documentation
For Testing, unittest
module is used for Test Suite and Assertion, whereas pytest
is being used for Test Runner and Coverage Reporter.
- Run the following command to initiate test:
pytest
- To include Coverage Reporting as well:
pytest --cov-report xml --cov=.
© MIT License