Sample Task Creation CRUD App
How to run the sample application Using Docker Compose 🐳
🪄 Dive into the world of Student CRUD Apps and see how seamlessly Keploy integrated with Flask and MongoDB Buckle up, it's gonna be a fun ride! 🎢
Don’t have Keploy installed yet?
Before running this sample, make sure Keploy is installed on your system.
👉 Go to Installation GuideClone a simple Student Management API 🧪
git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo
We will be using Docker compose to run the application as well as Mongo on Docker container.
Lights, Camera, Record! 🎥
Capture the test-cases-
keploy record -c "docker compose up" --container-name "flask-app" --buildDelay 50
🔥Make some API calls. Postman, Hoppscotch or even curl - take your pick!
Let's make URLs short and sweet:
Generate testcases
To generate testcases we just need to make some API calls.
- Make a POST request:
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students
- Make a GET request:
curl http://localhost:6000/students
- Make a PUT request:
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- Make a DELETE request:
curl -X DELETE http://localhost:6000/students/12345
And once you are done, you can stop the recording and give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the keploy directory and you'll discover your handiwork in tests
directory and mocks.yml
.
Want to see if everything works as expected?
Run Tests
Time to put things to the test 🧪
keploy test -c "docker compose up" --container-name "flask-app" --buildDelay 50 --delay 10
The
--delay
flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
Happy coding! ✨👩💻👨💻✨
How to Run the App Locally on Linux/WSL 🐧
🪄 Dive into the world of Student CRUD Apps and see how seamlessly Keploy integrated with Flask and MongoDB Buckle up, it's gonna be a fun ride! 🎢