- docker
- docker-compose
docker via the docker-compose.yml will be in charge of installing poetry and with it the python dependecies necessary to run the mongo service and the app.
once you have all dependencies installed, run this command to build and start the application:
docker-compose up
docker-compose run --rm web pytest -vv
if/when all tests pass you should be able to see all passing test including the code coverage
check for further testing configuration https://fastapi.tiangolo.com/tutorial/testing/
once the user is created in the db you should be able to get, update and delete the user
all get/list fields return users id for now, if more fields are needed feel free to update the UserResponse schema
- Endpoint: POST http://localhost:9008/api/v1/users
- Description: This endpoint is used to create a new user by sending a POST request with JSON data containing user information such as name, age, telephone, and created_at.
curl -X POST \
http://localhost:9008/api/v1/users \
-H 'Content-Type: application/json' \
-d '{
"name": "erick",
"age": 30,
"telephone": "1234567890",
"created_at": "2021-07-10T16:00:00"
}'
- Endpoint: GET http://localhost:9008/api/v1/users/
- Description: This endpoint retrieves information about all users
curl http://localhost:9008/api/v1/users/
remember to replace the {user_id} with the created user_id
- Endpoint: GET http://localhost:9008/api/v1/users/{user_id}
- Description: This endpoint retrieves information about a user specified by their unique identifier (user_id).
curl http://localhost:9008/api/v1/users/{user_id}
- Endpoint: PUT http://localhost:9008/api/v1/users/{user_id}
- Description: This endpoint updates an existing user's information with the provided data. It requires sending a PUT request with JSON data containing the fields to be updated.
curl -X PUT \
http://localhost:9008/api/v1/users/{user_id} \
-H 'Content-Type: application/json' \
-d '{
"name": "erick",
"age": 31,
"telephone": "1234567890"
}'
you should be able to update a single field by using the following curl
curl -X PUT \
http://localhost:9008/api/v1/users/{user_id} \
-H 'Content-Type: application/json' \
-d '{
"age": 31
}'
- Endpoint: DELETE http://localhost:9008/api/v1/users/{user_id}
- Description: This endpoint deletes an existing user specified by their unique identifier (user_id).
curl -X DELETE \
http://localhost:9008/api/v1/users/{user_id}
thanks @grillazz for the starting template