=====================================
This repository contains a Python + FastAPI microservice and API autotests
The microservice provides the following API endpoints:
GET /api/users: Returns a list of all usersGET /api/users/{user_id}: Returns a single user by IDPOST /api/users: Creates a new userPUT /api/users/{user_id}: Updates an existing userDELETE /api/users/{user_id}: Deletes a user
The microservice stores data in a text file for now, but will be migrated to a database in future iterations.
The API autotests cover the following scenarios:
- Successful creation of a new user
- Successful retrieval of a single user by ID
- Successful retrieval of a list of users
- Successful update of an existing user
- Successful deletion of a user
The test data is generated using the Faker library and is stored in the reqres_tests/utils directory.
To install the required dependencies, navigate to the repository root and execute the following command:
pip install -r requirements.txt
This will install the necessary dependencies, including FastAPI, Uvicorn, and Pytest.
To run the microservice execute the following command:
uvicorn reqres_app.main:app --reload
This will start the microservice on http://localhost:8000.
To run the autotests execute the following command:
pytest
The code is organized into the following directories:
reqres_app: Contains the FastAPI microservice code and the text file storing user datareqres_tests/utils: Contains utility files for test data generationtests: Contains the API autotests