From 41ba57fcccaaa8e8ab59c88fa604bb713f5b3c18 Mon Sep 17 00:00:00 2001 From: ahmedgamalyousef Date: Tue, 30 Sep 2025 23:30:46 +0300 Subject: [PATCH] Updating README.md file --- README.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7393745..bc83a6c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ + # 🍎 Fruit Store API A simple **RESTful API** built with Flask that manages fruits in a store. -The project also includes **logging**, a **log monitoring script**, and **automated testing script**. +The project also includes **logging**, a **log monitoring script**, and **automated testing script** with clear pass/fail output. --- ## 📂 Project Structure @@ -12,21 +13,21 @@ fruit-api/ │── Dockerfile # Docker support │── log_monitor.sh # Log monitoring script │── test_api.sh # Automated testing script +│── test_results.log # API test logs │── fruit_api.log # API logs │── README.md # Documentation │── .gitignore # Ignore venv/logs ``` - ## 📌 Features - CRUD operations on fruits (`GET`, `POST`, `PUT`, `DELETE`) - Search fruits by name - Filter fruits by category - Health check endpoint - Logging of all requests & responses to `fruit_api.log` -- Bash script for monitoring logs (`log_monitor.sh`) -- Bash script for automated API testing (`test_api.sh`) -- Swagger/OpenAPI documentation +- Bash script for monitoring logs (`log_monitor.sh`) with **error alerts (4xx/5xx)** +- Bash script for automated API testing (`test_api.sh`) with ✅ / ❌ results +- Swagger/OpenAPI documentation at `/docs` --- @@ -92,12 +93,12 @@ curl http://localhost:5000/fruits - **Add a fruit** ```bash -curl -X POST http://localhost:5000/fruits -H "Content-Type: application/json" -d '{"name":"Mango","color":"Yellow","price":2.5,"quantity":50,"category":"Tropical"}' +curl -X POST http://localhost:5000/fruits -H "Content-Type: application/json" -d '{"name":"Mango","color":"Yellow","price":2.5,"quantity":50,"category":"Tropical"}' ``` - **Update a fruit** ```bash -curl -X PUT http://localhost:5000/fruits/1 -H "Content-Type: application/json" -d '{"name":"Green Apple","price":1.8}' +curl -X PUT http://localhost:5000/fruits/1 -H "Content-Type: application/json" -d '{"name":"Green Apple","price":1.8}' ``` --- @@ -135,6 +136,7 @@ bash log_monitor.sh & The `test_api.sh` script: - Runs automated `GET`, `POST`, `PUT`, `DELETE` requests +- Prints ✅ if the status is correct (200/201), ❌ otherwise - Logs results in `test_results.log` Run tests: @@ -142,6 +144,17 @@ Run tests: bash test_api.sh ``` +Example output: +``` +🚀 Running API tests at Tue 30 Sep 2025 10:54:01 PM EEST +🔹 Testing /health ... ✅ +🔹 Testing GET /fruits ... ✅ +🔹 Testing POST /fruits ... ✅ +🔹 Testing PUT /fruits/1 ... ✅ +🔹 Testing DELETE /fruits/1 ... ✅ +✅ All tests passed! +``` + --- ## 📘 Swagger Documentation @@ -160,7 +173,3 @@ docker build -t fruit-api . ### Run container ```bash docker run -p 5000:5000 fruit-api -``` - ---- -