Skip to content

Commit 1d2676d

Browse files
committed
feat: add coverage in flask-mongo
Signed-off-by: Animesh Pathak <kurosakiichigo.songoku@gmail.com>
1 parent 4dcecf5 commit 1d2676d

File tree

6 files changed

+1359
-47
lines changed

6 files changed

+1359
-47
lines changed

flask-mongo/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ docker run -p 27017:27017 -d --network backend --name mongo mongo
3434

3535
```bash
3636
git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo
37+
pip3 install coverage
38+
pip3 install -r requirements.txt
3739
```
3840

3941
## Installation 📥

flask-mongo/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from pymongo import MongoClient
33
from flask_cors import CORS
44
import collections.abc
5+
from keploy import FlaskCoverageMiddleware
56

67
app = Flask(__name__)
78
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
9+
app.wsgi_app = FlaskCoverageMiddleware(app.wsgi_app)
810

911
# Connect to MongoDB
1012
client = MongoClient('mongodb://localhost:27017/')

flask-mongo/call.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students
22
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students
3+
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students
4+
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students
5+
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students
6+
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12346", "name": "Alice Green", "age": 22}' http://localhost:6000/students
7+
38
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12347", "name": "Bob Brown", "age": 24}' http://localhost:6000/students
49

510
curl http://localhost:6000/students

flask-mongo/keploy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*/mocks.yaml

0 commit comments

Comments
 (0)