diff --git a/flask-mongo/.coverage b/flask-mongo/.coverage
new file mode 100644
index 0000000..b9fdbfc
Binary files /dev/null and b/flask-mongo/.coverage differ
diff --git a/flask-mongo/.coveragerc b/flask-mongo/.coveragerc
new file mode 100644
index 0000000..387d12b
--- /dev/null
+++ b/flask-mongo/.coveragerc
@@ -0,0 +1,4 @@
+[run]
+omit =
+ /usr/*
+sigterm = true
\ No newline at end of file
diff --git a/flask-mongo/Dockerfile b/flask-mongo/Dockerfile
index cbefd2c..961d93b 100644
--- a/flask-mongo/Dockerfile
+++ b/flask-mongo/Dockerfile
@@ -1,5 +1,5 @@
# Use the official Python image as the base image
-FROM python:3.9
+FROM python:3.10.12
# Set the working directory within the container
WORKDIR /app
@@ -11,7 +11,7 @@ COPY . .
RUN pip3 install -r requirements.txt
# Expose the port that the Flask app will run on
-EXPOSE 6000
+EXPOSE 5000
# Start the Flask application
CMD ["python3", "app.py"]
diff --git a/flask-mongo/README.md b/flask-mongo/README.md
index 54bc693..2d79824 100644
--- a/flask-mongo/README.md
+++ b/flask-mongo/README.md
@@ -1,600 +1,102 @@
-This application is a simple student management API built using Python's Flask framework and MongoDB for data storage. It allows you to perform basic CRUD (Create, Read, Update, Delete) operations on student records. The API supports CORS (Cross-Origin Resource Sharing) to facilitate cross-domain requests.
+# Sample Flask+Mongo app to demo Keploy
-## Table of Contents
+## Clone the sample flask-mongo application
-# Introduction
+```bash
+git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo-local
+```
-๐ช Dive into the world of Student CRUD Apps and see how seamlessly Keploy integrated with [Flask](https://flask.palletsprojects.com/en/3.0.x/) and [MongoDB](https://www.mongodb.com/). Buckle up, it's gonna be a fun ride! ๐ข
+## Install all dependencies
-## Pre-Requisite ๐ ๏ธ
+```bash
+pip install -r requirements.txt
+```
-- Install WSL (`wsl --install`) for
Windows.
+## Start the MongoDB server
-## Optional ๐ ๏ธ
+```bash
+sudo service mongod start
+```
-- Install Colima( `brew install colima && colima start` ) for
MacOs.
+## Setup Keploy
-## Get Started! ๐ฌ
+Let's get started by setting up the Keploy alias with this command:
-## Setup the MongoDB Database ๐ฆ
+```bash
+curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
+```
-Create a docker network, run -
+You should see something like this:
```bash
-docker network create backend
+ โโโโโ
+ โโโโโโโโโโ
+ โโโโโโโโโโ
+ โโโโโโโ โโ โ โ
+ โโโโโโโโโโ โโ โโโ โโโโ โโโโ โโ โโโโโโ โโ โ
+ โโโโโโโโโโโโโ โโโโโ โโโโโ โโโ โโ โโ โโ โโ โโ โโ
+ โโโโโโโโโโโโโโโ โโ โโ โโโโ โโโโโโโ โโโ โโโโโโ โโโ
+ โโ โโโ โโ
+ โ
+
+Keploy CLI
+
+Available Commands:
+ example Example to record and test via keploy
+ generate-config generate the keploy configuration file
+ record record the keploy testcases from the API calls
+ test run the recorded testcases and execute assertions
+ update Update Keploy
+
+Flags:
+ --debug Run in debug mode
+ -h, --help help for keploy
+ -v, --version version for keploy
+
+Use "keploy [command] --help" for more information about a command.
```
-Start the MongoDB instance-
+## Lights, Camera, Record! ๐ฅ
+
+To initiate the recording of API calls, execute this command in your terminal:
```bash
-docker run -p 27017:27017 -d --network backend --name mongo mongo
+keploy record -c "python3 app.py"
```
-## Clone a simple Student Management API ๐งช
+Now, your app will start running, and you have to make some API calls!!
+
+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`.
+
+## Check Test Coverage
+
+We have a `test-app.py` where all the unit test cases has been written. Now using Keploy, we can check it's code coverage!!
+Now to run your unit tests with Keploy, you can run the command given below:
```bash
-git clone https://github.com/keploy/samples-python.git && cd samples-python/flask-mongo
+python3 -m coverage run -p --data-file=.coverage.unit -m pytest -s test_keploy.py test_app.py
```
-## Installation ๐ฅ
-
-Depending on your OS, choose your adventure:
+To combine the coverage from the unit tests, and Keploy's API tests we can use the command below:
--
-
Linux or
Windows
+```bash
+python3 -m coverage combine
+```
- Alright, let's equip ourselves with the **latest Keploy binary**:
+Finally, to generate the coverage report for the test run, you can run:
- ```bash
- curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp
+```bash
+python3 -m coverage report
+```
- sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy
- ```
+and if you want the coverage in an html file, you can run:
- If everything goes right, your screen should look a bit like this:
+```bash
+python3 -m coverage html
+```
- Moving on...
-
- Run App with
Docker
+## Wrapping it up ๐
- #### Add alias for Keploy:
+Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐๐
- ```bash
- alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy'
- ```
-
- ### Lights, Camera, Record! ๐ฅ
-
- Build the app image:
-
- ```bash
- docker build -t flask-app:1.0 .
- ```
-
- Capture the test-cases-
-
- ```shell
- keploy record -c "docker run -p 6000:6000 --name flask-app --network backend flask-app:1.0"
- ```
-
- ๐ฅ**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.**
-
- **1. Make a POST request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **2. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students
- ```
-
- **3. Make a PUT request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **4. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students/12345
- ```
-
- **5. Make a DELETE request**
-
- ```bash
- curl -X DELETE http://localhost:6000/students/12345
- ```
-
- 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 `test-1.yml` and `mocks.yml`.
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Http
- name: test-1
- spec:
- metadata: {}
- req:
- method: POST
- proto_major: 1
- proto_minor: 1
- url: http://localhost:6000/students
- header:
- Accept: "*/*"
- Content-Length: "56"
- Content-Type: application/json
- Host: localhost:6000
- User-Agent: curl/7.81.0
- body: '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- body_type: ""
- timestamp: 2023-11-13T13:02:32.241333562Z
- resp:
- status_code: 200
- header:
- Content-Length: "48"
- Content-Type: application/json
- Date: Mon, 13 Nov 2023 13:02:32 GMT
- Server: Werkzeug/2.2.2 Python/3.9.18
- body: |
- {
- "message": "Student created successfully"
- }
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- timestamp: 2023-11-13T13:02:34.752123715Z
- objects: []
- assertions:
- noise:
- - header.Date
- created: 1699880554
- curl: |-
- curl --request POST \
- --url http://localhost:6000/students \
- --header 'Host: localhost:6000' \
- --header 'User-Agent: curl/7.81.0' \
- --header 'Accept: */*' \
- --header 'Content-Type: application/json' \
- --data '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- ```
-
- This is how `mocks.yml` generated would look like:-
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Mongo
- name: mocks
- spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }'
- requests:
- - header:
- length: 187
- requestId: 2127584089
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }'
- checksum: 0
- read_delay: 3469848802
- responses:
- - header:
- length: 166
- requestId: 154
- responseTo: 2127584089
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"12345","name":"John Doe","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 869555
- created: 1699880576
- reqTimestampMock: 2023-11-13T13:02:56.385067848Z
- resTimestampMock: 2023-11-13T13:02:56.386374941Z
- ```
-
- Want to see if everything works as expected?
-
- #### Run Tests
-
- Time to put things to the test ๐งช
-
- ```shell
- keploy test -c "sudo docker run -p 6000:6000 --rm --network backend --name flask-app flask-app:1.0" --delay 10
- ```
-
- > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
-
- Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!โจ๐ฉโ๐ป๐จโ๐ปโจ
-
- ## Wrapping it up ๐
-
- Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐๐
-
- Happy coding! โจ๐ฉโ๐ป๐จโ๐ปโจ
-
-
-
-
-
- Run App on ๐ง Linux
-
- We'll be running our sample application right on Linux, but just to make things a tad more thrilling, we'll have the database (PostgreSQL) chill on Docker. Ready? Let's get the party started!๐
-
- ### ๐ผ Roll the Tape - Recording Time!
-
- Install the dependencies:
-
- ```bash
- pip install -r requirements.txt
- ```
-
- Now, let's Capture the test-cases-
-
- In `app.py`, replace the MongoDB connection URL with - `mongodb://0.0.0.0:27017/`
-
- Ready, set, record! Here's how:
-
- ```bash
- keploy record -c "python3 app.py"
- ```
-
- Keep an eye out for the `-c `flag! It's the command charm to run the app.
-
- Alright, magician! With the app alive and kicking, let's weave some test cases. The spell? Making some API calls! Postman, Hoppscotch, or the classic curl - pick your wand.
-
- ### Generate testcases
-
- To generate testcases we just need to **make some API calls.**
-
- **1. Make a POST request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **2. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students
- ```
-
- **3. Make a PUT request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **4. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students/12345
- ```
-
- **5. Make a DELETE request**
-
- ```bash
- curl -X DELETE http://localhost:6000/students/12345
- ```
-
- 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 `test-1.yml` and `mocks.yml`.
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Http
- name: test-1
- spec:
- metadata: {}
- req:
- method: POST
- proto_major: 1
- proto_minor: 1
- url: http://localhost:6000/students
- header:
- Accept: "*/*"
- Content-Length: "56"
- Content-Type: application/json
- Host: localhost:6000
- User-Agent: curl/7.81.0
- body: '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- body_type: ""
- timestamp: 2023-11-13T13:02:32.241333562Z
- resp:
- status_code: 200
- header:
- Content-Length: "48"
- Content-Type: application/json
- Date: Mon, 13 Nov 2023 13:02:32 GMT
- Server: Werkzeug/2.2.2 Python/3.9.18
- body: |
- {
- "message": "Student created successfully"
- }
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- timestamp: 2023-11-13T13:02:34.752123715Z
- objects: []
- assertions:
- noise:
- - header.Date
- created: 1699880554
- curl: |-
- curl --request POST \
- --url http://localhost:6000/students \
- --header 'Host: localhost:6000' \
- --header 'User-Agent: curl/7.81.0' \
- --header 'Accept: */*' \
- --header 'Content-Type: application/json' \
- --data '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- ```
-
- This is how `mocks.yml` generated would look like:-
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Mongo
- name: mocks
- spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }'
- requests:
- - header:
- length: 187
- requestId: 2127584089
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }'
- checksum: 0
- read_delay: 3469848802
- responses:
- - header:
- length: 166
- requestId: 154
- responseTo: 2127584089
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"12345","name":"John Doe","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 869555
- created: 1699880576
- reqTimestampMock: 2023-11-13T13:02:56.385067848Z
- resTimestampMock: 2023-11-13T13:02:56.386374941Z
- ```
-
- Want to see if everything works as expected?
-
- #### Run Tests
-
- Time to put things to the test ๐งช
-
- ```shell
- keploy test -c "python3 app.py" --delay 10
- ```
-
- > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
-
- Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!โจ๐ฉโ๐ป๐จโ๐ปโจ
-
- ## Wrapping it up ๐
-
- Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible. ๐๐
-
- Happy coding! โจ๐ฉโ๐ป๐จโ๐ปโจ
-
-
-
-
-
-
--
-
MacOs
-
- Dive straight in, but first in case you're using **Keploy** with **Colima**, give it a gentle nudge with (`colima start`). Let's make sure it's awake and ready for action!
-
- ### Add alias for Keploy ๐ฐ:
-
- For the sake of convenience (and a bit of Mac magic ๐ช), let's set up a shortcut for Keploy:
-
- ### Use Keploy with Docker-Desktop
-
- Note: To run Keploy on MacOS through [Docker](https://docs.docker.com/desktop/release-notes/#4252) the version must be `4.25.2` or above.
-
- #### Creating Docker Volume
-
- ```bash
- docker volume create --driver local --opt type=debugfs --opt device=debugfs debugfs
- ```
-
- ```bash
- alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v debugfs:/sys/kernel/debug:rw -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy'
- ```
-
- ### Use Keploy with Colima
-
- ```bash
- alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock -v '"$HOME"'/.keploy-config:/root/.keploy-config -v '"$HOME"'/.keploy:/root/.keploy --rm ghcr.io/keploy/keploy'
- ```
-
- ### Lights, Camera, Record! ๐ฅ
-
- Build the app image:
-
- ```bash
- docker build -t flask-app:1.0 .
- ```
-
- Capture the test-cases-
-
- ```shell
- keploy record -c "docker run -p 6000:6000 --name DjangoApp --network backend --name flask-app flask-app:1.0"
- ```
-
- ๐ฅ**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.**
-
- **1. Make a POST request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **2. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students
- ```
-
- **3. Make a PUT request**
-
- ```bash
- curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
- ```
-
- **4. Make a GET request**
-
- ```bash
- curl http://localhost:6000/students/12345
- ```
-
- **5. Make a DELETE request**
-
- ```bash
- curl -X DELETE http://localhost:6000/students/12345
- ```
-
- 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 `test-1.yml` and `mocks.yml`.
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Http
- name: test-1
- spec:
- metadata: {}
- req:
- method: POST
- proto_major: 1
- proto_minor: 1
- url: http://localhost:6000/students
- header:
- Accept: "*/*"
- Content-Length: "56"
- Content-Type: application/json
- Host: localhost:6000
- User-Agent: curl/7.81.0
- body: '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- body_type: ""
- timestamp: 2023-11-13T13:02:32.241333562Z
- resp:
- status_code: 200
- header:
- Content-Length: "48"
- Content-Type: application/json
- Date: Mon, 13 Nov 2023 13:02:32 GMT
- Server: Werkzeug/2.2.2 Python/3.9.18
- body: |
- {
- "message": "Student created successfully"
- }
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- timestamp: 2023-11-13T13:02:34.752123715Z
- objects: []
- assertions:
- noise:
- - header.Date
- created: 1699880554
- curl: |-
- curl --request POST \
- --url http://localhost:6000/students \
- --header 'Host: localhost:6000' \
- --header 'User-Agent: curl/7.81.0' \
- --header 'Accept: */*' \
- --header 'Content-Type: application/json' \
- --data '{"student_id": "12344", "name": "John Doeww", "age": 10}'
- ```
-
- This is how `mocks.yml` generated would look like:-
-
- ```yaml
- version: api.keploy.io/v1beta2
- kind: Mongo
- name: mocks
- spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }'
- requests:
- - header:
- length: 187
- requestId: 2127584089
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"find":"students","filter":{"student_id":"12345"},"projection":{"_id":{"$numberInt":"0"}},"limit":{"$numberInt":"1"},"singleBatch":true,"lsid":{"id":{"$binary":{"base64":"vPKsEFRdTLytlbnyVimqIA==","subType":"04"}}},"$db":"studentsdb"} }'
- checksum: 0
- read_delay: 3469848802
- responses:
- - header:
- length: 166
- requestId: 154
- responseTo: 2127584089
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"12345","name":"John Doe","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 869555
- created: 1699880576
- reqTimestampMock: 2023-11-13T13:02:56.385067848Z
- resTimestampMock: 2023-11-13T13:02:56.386374941Z
- ```
-
- Want to see if everything works as expected?
-
- #### Run Tests
-
- Time to put things to the test ๐งช
-
- ```shell
- keploy test -c "sudo docker run -p 6000:6000 --rm --network backend --name flask-app flask-app:1.0" --delay 10
- ```
-
- > The `--delay` flag? Oh, that's just giving your app a little breather (in seconds) before the test cases come knocking.
-
- Final thoughts? Dive deeper! Try different API calls, tweak the DB response in the `mocks.yml`, or fiddle with the request or response in `test-x.yml`. Run the tests again and see the magic unfold!โจ๐ฉโ๐ป๐จโ๐ปโจ
-
- ## Wrapping it up ๐
-
- Congrats on the journey so far! You've seen Keploy's power, flexed your coding muscles, and had a bit of fun too! Now, go out there and keep exploring, innovating, and creating! Remember, with the right tools and a sprinkle of fun, anything's possible.๐๐
-
- Happy coding! โจ๐ฉโ๐ป๐จโ๐ปโจ
-
+Happy coding! โจ๐ฉโ๐ป๐จโ๐ปโจ
diff --git a/flask-mongo/__pycache__/app.cpython-310.pyc b/flask-mongo/__pycache__/app.cpython-310.pyc
new file mode 100644
index 0000000..e502979
Binary files /dev/null and b/flask-mongo/__pycache__/app.cpython-310.pyc differ
diff --git a/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc b/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc
new file mode 100644
index 0000000..ca0d856
Binary files /dev/null and b/flask-mongo/__pycache__/test_app.cpython-310-pytest-8.1.1.pyc differ
diff --git a/flask-mongo/__pycache__/test_app.cpython-310.pyc b/flask-mongo/__pycache__/test_app.cpython-310.pyc
new file mode 100644
index 0000000..e052133
Binary files /dev/null and b/flask-mongo/__pycache__/test_app.cpython-310.pyc differ
diff --git a/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc b/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc
new file mode 100644
index 0000000..f77eaa0
Binary files /dev/null and b/flask-mongo/__pycache__/test_keploy.cpython-310-pytest-8.1.1.pyc differ
diff --git a/flask-mongo/app.py b/flask-mongo/app.py
index 6e31416..730db9f 100644
--- a/flask-mongo/app.py
+++ b/flask-mongo/app.py
@@ -1,42 +1,56 @@
from flask import Flask, request, jsonify
from pymongo import MongoClient
from flask_cors import CORS
-import collections.abc
+from bson import ObjectId
app = Flask(__name__)
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
-# Connect to MongoDB
-client = MongoClient('mongodb://mongo:27017/')
-db = client['studentsdb']
-students_collection = db['students']
-
-@app.route('/students', methods=['GET'])
-def get_students():
- students = list(students_collection.find({}, {'_id': 0}))
- return jsonify(students)
-
-@app.route('/students/', methods=['GET'])
-def get_student(student_id):
- student = students_collection.find_one({'student_id': student_id}, {'_id': 0})
- return jsonify(student)
-
-@app.route('/students', methods=['POST'])
-def create_student():
- new_student = request.json
- students_collection.insert_one(new_student)
- return jsonify({'message': 'Student created successfully'})
-
-@app.route('/students/', methods=['PUT'])
-def update_student(student_id):
- updated_student = request.json
- students_collection.update_one({'student_id': student_id}, {'$set': updated_student})
- return jsonify({'message': 'Student updated successfully'})
-
-@app.route('/students/', methods=['DELETE'])
-def delete_student(student_id):
- students_collection.delete_one({'student_id': student_id})
- return jsonify({'message': 'Student deleted successfully'})
+client = MongoClient('mongodb://localhost:27017/task_manager')
+db = client['task_manager']
+collection = db['tasks']
+
+@app.route('/api/tasks', methods=['POST'])
+def create_task():
+ data = request.get_json()
+ task = {
+ 'title': data['title'],
+ 'description': data['description']
+ }
+ result = collection.insert_one(task)
+ return jsonify({'message': 'Task created successfully', 'id': str(result.inserted_id)}), 201
+
+@app.route('/api/tasks', methods=['GET'])
+def get_all_tasks():
+ tasks = []
+ for task in collection.find():
+ tasks.append({
+ 'id': str(task['_id']),
+ 'title': task['title'],
+ 'description': task['description']
+ })
+ return jsonify({'tasks': tasks})
+
+@app.route('/api/tasks/', methods=['PUT'])
+def update_task(task_id):
+ data = request.get_json()
+ updated_task = {
+ 'title': data['title'],
+ 'description': data['description']
+ }
+ try:
+ result = collection.update_one({'_id': ObjectId(task_id)}, {'$set': updated_task})
+ if result.modified_count == 0:
+ return jsonify({'error': 'Task not found or no changes were made'}), 404
+ else:
+ return jsonify({'message': 'Task updated successfully'})
+ except Exception as e:
+ return jsonify({'error': str(e)}), 500
+
+@app.route('/api/tasks/', methods=['DELETE'])
+def delete_task(task_id):
+ collection.delete_one({'_id': ObjectId(task_id)})
+ return jsonify({'message': 'Task deleted successfully'})
if __name__ == '__main__':
- app.run(host='0.0.0.0', port=6000, debug=True)
+ app.run(host='0.0.0.0', port=5000, debug=True)
diff --git a/flask-mongo/docker-compose.yml b/flask-mongo/docker-compose.yml
index 7ef7346..1d71e32 100644
--- a/flask-mongo/docker-compose.yml
+++ b/flask-mongo/docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3'
+version: "3"
services:
mongo:
image: mongo
@@ -16,7 +16,7 @@ services:
build:
context: .
ports:
- - "6000:6000"
+ - "5000:5000"
depends_on:
- mongo
networks:
diff --git a/flask-mongo/keploy/reports/test-run-0/test-set-0-report.yaml b/flask-mongo/keploy/reports/test-run-0/test-set-0-report.yaml
new file mode 100644
index 0000000..c4c5d3c
--- /dev/null
+++ b/flask-mongo/keploy/reports/test-run-0/test-set-0-report.yaml
@@ -0,0 +1,446 @@
+version: api.keploy.io/v1beta1
+name: test-set-0-report
+status: FAILED
+success: 0
+failure: 4
+total: 4
+tests:
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873653
+ completed: 1713873653
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-1
+ req:
+ method: GET
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "59"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Task 6","description": "Description for Task 6"}'
+ timestamp: 2024-04-22T16:38:39.232565209+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "267"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:08:39 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "tasks": [
+ {
+ "description": "should update",
+ "id": "6626362fc7c5eddf174c88e4",
+ "title": "Updated"
+ },
+ {
+ "description": "Should work",
+ "id": "66263667c7c5eddf174c88e5",
+ "title": "Let's Check another time"
+ }
+ ]
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:38:41.245704918+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:08:39 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:00:53 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "267"
+ actual:
+ key: Content-Length
+ value:
+ - "191"
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "tasks": [
+ {
+ "description": "should update",
+ "id": "6626362fc7c5eddf174c88e4",
+ "title": "Updated"
+ },
+ {
+ "description": "Should work",
+ "id": "66263667c7c5eddf174c88e5",
+ "title": "Let's Check another time"
+ }
+ ]
+ }
+ actual: |
+ {"tasks":[{"description":"should update","id":"6626362fc7c5eddf174c88e4","title":"Updated"},{"description":"Should work","id":"66263667c7c5eddf174c88e5","title":"Let's Check another time"}]}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873653
+ completed: 1713873653
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-2
+ req:
+ method: POST
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "57"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title":"Hey, let''s Check","description":"It will work"}'
+ timestamp: 2024-04-22T16:39:05.814517536+05:30
+ resp:
+ status_code: 201
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "81"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:05 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "id": "66264551a6e962a1cbd50429",
+ "message": "Task created successfully"
+ }
+ status_message: Created
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:07.866639952+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 201
+ actual: 201
+ headers_result:
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "81"
+ actual:
+ key: Content-Length
+ value:
+ - "72"
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:09:05 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:00:53 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ body_result:
+ - normal: false
+ type: JSON
+ expected: |
+ {
+ "id": "66264551a6e962a1cbd50429",
+ "message": "Task created successfully"
+ }
+ actual: |
+ {"id":"6627a2f5a20cac37a4bb3d0f","message":"Task created successfully"}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873653
+ completed: 1713873653
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-3
+ req:
+ method: PUT
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "53"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Updated again","description": "hey there"}'
+ timestamp: 2024-04-22T16:39:52.181533473+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:52 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task updated successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:54.273657454+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "45"
+ actual:
+ key: Content-Length
+ value:
+ - "40"
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:09:52 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:00:53 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "message": "Task updated successfully"
+ }
+ actual: |
+ {"message":"Task updated successfully"}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873653
+ completed: 1713873653
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-4
+ req:
+ method: DELETE
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Host: localhost:5000
+ Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6
+ User-Agent: PostmanRuntime/7.32.1
+ body: ""
+ timestamp: 2024-04-22T16:40:08.615353613+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:10:08 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task deleted successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:40:10.646676187+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "45"
+ actual:
+ key: Content-Length
+ value:
+ - "40"
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:10:08 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:00:53 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "message": "Task deleted successfully"
+ }
+ actual: |
+ {"message":"Task deleted successfully"}
+ dep_result: []
+test_set: test-set-0
diff --git a/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml b/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml
new file mode 100644
index 0000000..61157f7
--- /dev/null
+++ b/flask-mongo/keploy/reports/test-run-1/test-set-0-report.yaml
@@ -0,0 +1,446 @@
+version: api.keploy.io/v1beta1
+name: test-set-0-report
+status: FAILED
+success: 0
+failure: 4
+total: 4
+tests:
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873824
+ completed: 1713873824
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-1
+ req:
+ method: GET
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "59"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Task 6","description": "Description for Task 6"}'
+ timestamp: 2024-04-22T16:38:39.232565209+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "267"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:08:39 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "tasks": [
+ {
+ "description": "should update",
+ "id": "6626362fc7c5eddf174c88e4",
+ "title": "Updated"
+ },
+ {
+ "description": "Should work",
+ "id": "66263667c7c5eddf174c88e5",
+ "title": "Let's Check another time"
+ }
+ ]
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:38:41.245704918+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:08:39 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:03:44 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "267"
+ actual:
+ key: Content-Length
+ value:
+ - "191"
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "tasks": [
+ {
+ "description": "should update",
+ "id": "6626362fc7c5eddf174c88e4",
+ "title": "Updated"
+ },
+ {
+ "description": "Should work",
+ "id": "66263667c7c5eddf174c88e5",
+ "title": "Let's Check another time"
+ }
+ ]
+ }
+ actual: |
+ {"tasks":[{"description":"should update","id":"6626362fc7c5eddf174c88e4","title":"Updated"},{"description":"Should work","id":"66263667c7c5eddf174c88e5","title":"Let's Check another time"}]}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873824
+ completed: 1713873824
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-2
+ req:
+ method: POST
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "57"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title":"Hey, let''s Check","description":"It will work"}'
+ timestamp: 2024-04-22T16:39:05.814517536+05:30
+ resp:
+ status_code: 201
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "81"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:05 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "id": "66264551a6e962a1cbd50429",
+ "message": "Task created successfully"
+ }
+ status_message: Created
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:07.866639952+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 201
+ actual: 201
+ headers_result:
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:09:05 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:03:44 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "81"
+ actual:
+ key: Content-Length
+ value:
+ - "72"
+ body_result:
+ - normal: false
+ type: JSON
+ expected: |
+ {
+ "id": "66264551a6e962a1cbd50429",
+ "message": "Task created successfully"
+ }
+ actual: |
+ {"id":"6627a3a0dcedca8503554d0d","message":"Task created successfully"}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873824
+ completed: 1713873824
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-3
+ req:
+ method: PUT
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "53"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Updated again","description": "hey there"}'
+ timestamp: 2024-04-22T16:39:52.181533473+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:52 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task updated successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:54.273657454+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:09:52 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:03:44 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "45"
+ actual:
+ key: Content-Length
+ value:
+ - "40"
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "message": "Task updated successfully"
+ }
+ actual: |
+ {"message":"Task updated successfully"}
+ dep_result: []
+ - kind: Http
+ name: test-set-0
+ status: FAILED
+ started: 1713873824
+ completed: 1713873824
+ test_case_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0
+ mock_path: /mnt/c/Users/swapn/Downloads/samples-python/flask-mongo-local/keploy/test-set-0/mocks.yaml
+ test_case_id: test-4
+ req:
+ method: DELETE
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Host: localhost:5000
+ Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6
+ User-Agent: PostmanRuntime/7.32.1
+ body: ""
+ timestamp: 2024-04-22T16:40:08.615353613+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:10:08 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task deleted successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:40:10.646676187+05:30
+ noise:
+ header.Date: []
+ result:
+ status_code:
+ normal: true
+ expected: 200
+ actual: 200
+ headers_result:
+ - normal: false
+ expected:
+ key: Content-Length
+ value:
+ - "45"
+ actual:
+ key: Content-Length
+ value:
+ - "40"
+ - normal: true
+ expected:
+ key: Content-Type
+ value:
+ - application/json
+ actual:
+ key: Content-Type
+ value:
+ - application/json
+ - normal: true
+ expected:
+ key: Date
+ value:
+ - Mon, 22 Apr 2024 11:10:08 GMT
+ actual:
+ key: Date
+ value:
+ - Tue, 23 Apr 2024 12:03:44 GMT
+ - normal: true
+ expected:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ actual:
+ key: Server
+ value:
+ - Werkzeug/3.0.2 Python/3.10.12
+ - normal: true
+ expected:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ actual:
+ key: Access-Control-Allow-Origin
+ value:
+ - '*'
+ body_result:
+ - normal: true
+ type: JSON
+ expected: |
+ {
+ "message": "Task deleted successfully"
+ }
+ actual: |
+ {"message":"Task deleted successfully"}
+ dep_result: []
+test_set: test-set-0
diff --git a/flask-mongo/keploy/test-set-0/mocks.yaml b/flask-mongo/keploy/test-set-0/mocks.yaml
new file mode 100644
index 0000000..8b4d319
--- /dev/null
+++ b/flask-mongo/keploy/test-set-0/mocks.yaml
@@ -0,0 +1,319 @@
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-0
+spec:
+ metadata:
+ operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.6.3"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0"}}, returnFieldsSelector: }'
+ type: config
+ requests:
+ - header:
+ length: 283
+ requestId: 1804289383
+ responseTo: 0
+ Opcode: 2004
+ message:
+ flags: 0
+ collection_name: admin.$cmd
+ number_to_skip: 0
+ number_to_return: -1
+ query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.6.3"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0"}}'
+ return_fields_selector: ""
+ responses:
+ - header:
+ length: 329
+ requestId: 238
+ responseTo: 1804289383
+ Opcode: 1
+ message:
+ response_flags: 8
+ cursor_id: 0
+ starting_from: 0
+ number_returned: 1
+ documents:
+ - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784113763"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"18"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
+ read_delay: 1010011
+ created: 1713784113
+ reqTimestampMock: 2024-04-22T16:38:33.762559618+05:30
+ resTimestampMock: 2024-04-22T16:38:33.763749062+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-1
+spec:
+ metadata:
+ operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.6.3"},"os": {"type": "Linux","name": "Linux","architecture": "x86_64","version": "5.15.146.1-microsoft-standard-WSL2"},"platform": "CPython 3.10.12.final.0"},"compression": []}, returnFieldsSelector: }'
+ type: config
+ requests:
+ - header:
+ length: 301
+ requestId: 1714636915
+ responseTo: 0
+ Opcode: 2004
+ message:
+ flags: 0
+ collection_name: admin.$cmd
+ number_to_skip: 0
+ number_to_return: -1
+ query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.6.3"},"os":{"type":"Linux","name":"Linux","architecture":"x86_64","version":"5.15.146.1-microsoft-standard-WSL2"},"platform":"CPython 3.10.12.final.0"},"compression":[]}'
+ return_fields_selector: ""
+ responses:
+ - header:
+ length: 329
+ requestId: 242
+ responseTo: 1714636915
+ Opcode: 1
+ message:
+ response_flags: 8
+ cursor_id: 0
+ starting_from: 0
+ number_returned: 1
+ documents:
+ - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784119236"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"22"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
+ read_delay: 527460
+ created: 1713784119
+ reqTimestampMock: 2024-04-22T16:38:39.236318621+05:30
+ resTimestampMock: 2024-04-22T16:38:39.236994457+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-2
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"tasks","filter":{},"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }], checksum: 0 }'
+ requests:
+ - header:
+ length: 113
+ requestId: 1957747793
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"find":"tasks","filter":{},"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }'
+ checksum: 0
+ read_delay: 336283
+ responses:
+ - header:
+ length: 272
+ requestId: 243
+ responseTo: 1957747793
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"_id":{"$oid":"6626362fc7c5eddf174c88e4"},"title":"Updated","description":"should update"},{"_id":{"$oid":"66263667c7c5eddf174c88e5"},"title":"Let''s Check another time","description":"Should work"}],"id":{"$numberLong":"0"},"ns":"task_manager.tasks"},"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 712174
+ created: 1713784119
+ reqTimestampMock: 2024-04-22T16:38:39.237446806+05:30
+ resTimestampMock: 2024-04-22T16:38:39.238329738+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-3
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }'
+ type: config
+ requests:
+ - header:
+ length: 134
+ requestId: 846930886
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 65536
+ sections:
+ - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }'
+ checksum: 0
+ read_delay: 2621927
+ responses:
+ - header:
+ length: 313
+ requestId: 244
+ responseTo: 846930886
+ Opcode: 2013
+ message:
+ flagBits: 2
+ sections:
+ - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784123771"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"18"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 10005242839
+ created: 1713784123
+ reqTimestampMock: 2024-04-22T16:38:33.766550283+05:30
+ resTimestampMock: 2024-04-22T16:38:43.772009113+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-4
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }'
+ type: config
+ requests:
+ - header:
+ length: 52
+ requestId: 1714636915
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }'
+ checksum: 0
+ read_delay: 10012944393
+ responses:
+ - header:
+ length: 313
+ requestId: 245
+ responseTo: 1714636915
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784123781"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"19"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 458361
+ created: 1713784123
+ reqTimestampMock: 2024-04-22T16:38:43.781318376+05:30
+ resTimestampMock: 2024-04-22T16:38:43.781975276+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-5
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }'
+ type: config
+ requests:
+ - header:
+ length: 65
+ requestId: 1957747793
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }'
+ checksum: 0
+ read_delay: 10012662732
+ responses:
+ - header:
+ length: 314
+ requestId: 249
+ responseTo: 1957747793
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"6626352423399d438e00b0cf"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1713784133794"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"19"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"21"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 430352
+ created: 1713784133
+ reqTimestampMock: 2024-04-22T16:38:53.794777057+05:30
+ resTimestampMock: 2024-04-22T16:38:53.795333713+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-6
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"66264551a6e962a1cbd50429"},"title":"Hey, let''s Check","description":"It will work"} ] }], checksum: 0 }'
+ requests:
+ - header:
+ length: 207
+ requestId: 596516649
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"insert":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }'
+ - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"66264551a6e962a1cbd50429"},"title":"Hey, let''s Check","description":"It will work"} ] }'
+ checksum: 0
+ read_delay: 26577872780
+ responses:
+ - header:
+ length: 45
+ requestId: 256
+ responseTo: 596516649
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 5437683
+ created: 1713784145
+ reqTimestampMock: 2024-04-22T16:39:05.816402038+05:30
+ resTimestampMock: 2024-04-22T16:39:05.822001482+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-7
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"update":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6626362fc7c5eddf174c88e4"}},"u":{"$set":{"title":"Updated again","description":"hey there"}},"multi":false,"upsert":false} ] }], checksum: 0 }'
+ requests:
+ - header:
+ length: 243
+ requestId: 1102520059
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"update":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }'
+ - '{ SectionSingle identifier: updates , msgs: [ {"q":{"_id":{"$oid":"6626362fc7c5eddf174c88e4"}},"u":{"$set":{"title":"Updated again","description":"hey there"}},"multi":false,"upsert":false} ] }'
+ checksum: 0
+ read_delay: 46361192429
+ responses:
+ - header:
+ length: 60
+ requestId: 273
+ responseTo: 1102520059
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"nModified":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 5673350
+ created: 1713784192
+ reqTimestampMock: 2024-04-22T16:39:52.183391788+05:30
+ resTimestampMock: 2024-04-22T16:39:52.189223944+05:30
+---
+version: api.keploy.io/v1beta1
+kind: Mongo
+name: mock-8
+spec:
+ metadata:
+ operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"delete":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }, { SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"66263667c7c5eddf174c88e5"}},"limit":{"$numberInt":"1"}} ] }], checksum: 0 }'
+ requests:
+ - header:
+ length: 166
+ requestId: 1365180540
+ responseTo: 0
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"delete":"tasks","ordered":true,"lsid":{"id":{"$binary":{"base64":"2JJr5nwqRNe8aRUchma6xQ==","subType":"04"}}},"$db":"task_manager"} }'
+ - '{ SectionSingle identifier: deletes , msgs: [ {"q":{"_id":{"$oid":"66263667c7c5eddf174c88e5"}},"limit":{"$numberInt":"1"}} ] }'
+ checksum: 0
+ read_delay: 16427108137
+ responses:
+ - header:
+ length: 45
+ requestId: 286
+ responseTo: 1365180540
+ Opcode: 2013
+ message:
+ flagBits: 0
+ sections:
+ - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
+ checksum: 0
+ read_delay: 1386879
+ created: 1713784208
+ reqTimestampMock: 2024-04-22T16:40:08.616520091+05:30
+ resTimestampMock: 2024-04-22T16:40:08.61802554+05:30
diff --git a/flask-mongo/keploy/test-set-0/tests/test-1.yaml b/flask-mongo/keploy/test-set-0/tests/test-1.yaml
new file mode 100644
index 0000000..fae2cc0
--- /dev/null
+++ b/flask-mongo/keploy/test-set-0/tests/test-1.yaml
@@ -0,0 +1,66 @@
+version: api.keploy.io/v1beta1
+kind: Http
+name: test-1
+spec:
+ metadata: {}
+ req:
+ method: GET
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "59"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Task 6","description": "Description for Task 6"}'
+ timestamp: 2024-04-22T16:38:39.232565209+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "267"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:08:39 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "tasks": [
+ {
+ "description": "should update",
+ "id": "6626362fc7c5eddf174c88e4",
+ "title": "Updated"
+ },
+ {
+ "description": "Should work",
+ "id": "66263667c7c5eddf174c88e5",
+ "title": "Let's Check another time"
+ }
+ ]
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:38:41.245704918+05:30
+ objects: []
+ assertions:
+ noise:
+ header.Date: []
+ created: 1713784121
+curl: |-
+ curl --request GET \
+ --url http://localhost:5000/api/tasks \
+ --header 'Host: localhost:5000' \
+ --header 'User-Agent: PostmanRuntime/7.32.1' \
+ --header 'Accept: */*' \
+ --header 'Content-Type: application/json' \
+ --header 'Connection: keep-alive' \
+ --header 'Cache-Control: no-cache' \
+ --header 'Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1' \
+ --header 'Accept-Encoding: gzip, deflate, br' \
+ --data '{"title": "Task 6","description": "Description for Task 6"}'
diff --git a/flask-mongo/keploy/test-set-0/tests/test-2.yaml b/flask-mongo/keploy/test-set-0/tests/test-2.yaml
new file mode 100644
index 0000000..640154f
--- /dev/null
+++ b/flask-mongo/keploy/test-set-0/tests/test-2.yaml
@@ -0,0 +1,56 @@
+version: api.keploy.io/v1beta1
+kind: Http
+name: test-2
+spec:
+ metadata: {}
+ req:
+ method: POST
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "57"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title":"Hey, let''s Check","description":"It will work"}'
+ timestamp: 2024-04-22T16:39:05.814517536+05:30
+ resp:
+ status_code: 201
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "81"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:05 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "id": "66264551a6e962a1cbd50429",
+ "message": "Task created successfully"
+ }
+ status_message: Created
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:07.866639952+05:30
+ objects: []
+ assertions:
+ noise:
+ header.Date: []
+ created: 1713784147
+curl: |-
+ curl --request POST \
+ --url http://localhost:5000/api/tasks \
+ --header 'Accept-Encoding: gzip, deflate, br' \
+ --header 'Connection: keep-alive' \
+ --header 'User-Agent: PostmanRuntime/7.32.1' \
+ --header 'Host: localhost:5000' \
+ --header 'Cache-Control: no-cache' \
+ --header 'Accept: */*' \
+ --header 'Postman-Token: 7aabbe61-38ec-4169-a4d8-31cb3546ca01' \
+ --header 'Content-Type: application/json' \
+ --data '{"title":"Hey, let's Check","description":"It will work"}'
diff --git a/flask-mongo/keploy/test-set-0/tests/test-3.yaml b/flask-mongo/keploy/test-set-0/tests/test-3.yaml
new file mode 100644
index 0000000..3844c87
--- /dev/null
+++ b/flask-mongo/keploy/test-set-0/tests/test-3.yaml
@@ -0,0 +1,55 @@
+version: api.keploy.io/v1beta1
+kind: Http
+name: test-3
+spec:
+ metadata: {}
+ req:
+ method: PUT
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Content-Length: "53"
+ Content-Type: application/json
+ Host: localhost:5000
+ Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3
+ User-Agent: PostmanRuntime/7.32.1
+ body: '{"title": "Updated again","description": "hey there"}'
+ timestamp: 2024-04-22T16:39:52.181533473+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:09:52 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task updated successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:39:54.273657454+05:30
+ objects: []
+ assertions:
+ noise:
+ header.Date: []
+ created: 1713784194
+curl: |-
+ curl --request PUT \
+ --url http://localhost:5000/api/tasks/6626362fc7c5eddf174c88e4 \
+ --header 'Accept: */*' \
+ --header 'Content-Type: application/json' \
+ --header 'User-Agent: PostmanRuntime/7.32.1' \
+ --header 'Host: localhost:5000' \
+ --header 'Accept-Encoding: gzip, deflate, br' \
+ --header 'Cache-Control: no-cache' \
+ --header 'Postman-Token: 89d42b67-eafb-474e-ac5a-1df4982a9fe3' \
+ --header 'Connection: keep-alive' \
+ --data '{"title": "Updated again","description": "hey there"}'
diff --git a/flask-mongo/keploy/test-set-0/tests/test-4.yaml b/flask-mongo/keploy/test-set-0/tests/test-4.yaml
new file mode 100644
index 0000000..9888fea
--- /dev/null
+++ b/flask-mongo/keploy/test-set-0/tests/test-4.yaml
@@ -0,0 +1,51 @@
+version: api.keploy.io/v1beta1
+kind: Http
+name: test-4
+spec:
+ metadata: {}
+ req:
+ method: DELETE
+ proto_major: 1
+ proto_minor: 1
+ url: http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5
+ header:
+ Accept: '*/*'
+ Accept-Encoding: gzip, deflate, br
+ Cache-Control: no-cache
+ Connection: keep-alive
+ Host: localhost:5000
+ Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6
+ User-Agent: PostmanRuntime/7.32.1
+ body: ""
+ timestamp: 2024-04-22T16:40:08.615353613+05:30
+ resp:
+ status_code: 200
+ header:
+ Access-Control-Allow-Origin: '*'
+ Content-Length: "45"
+ Content-Type: application/json
+ Date: Mon, 22 Apr 2024 11:10:08 GMT
+ Server: Werkzeug/3.0.2 Python/3.10.12
+ body: |
+ {
+ "message": "Task deleted successfully"
+ }
+ status_message: OK
+ proto_major: 0
+ proto_minor: 0
+ timestamp: 2024-04-22T16:40:10.646676187+05:30
+ objects: []
+ assertions:
+ noise:
+ header.Date: []
+ created: 1713784210
+curl: |
+ curl --request DELETE \
+ --url http://localhost:5000/api/tasks/66263667c7c5eddf174c88e5 \
+ --header 'Accept-Encoding: gzip, deflate, br' \
+ --header 'Connection: keep-alive' \
+ --header 'User-Agent: PostmanRuntime/7.32.1' \
+ --header 'Accept: */*' \
+ --header 'Cache-Control: no-cache' \
+ --header 'Postman-Token: 0f3d6037-f57c-4fb3-be52-e6ffed1566e6' \
+ --header 'Host: localhost:5000' \
diff --git a/flask-mongo/keploy/test-set-1/config.yaml b/flask-mongo/keploy/test-set-1/config.yaml
deleted file mode 100755
index e451518..0000000
--- a/flask-mongo/keploy/test-set-1/config.yaml
+++ /dev/null
@@ -1,167 +0,0 @@
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: config
-spec:
- metadata:
- operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.4.1"},"os": {"type": "Linux","name": "Linux","architecture": "aarch64","version": "6.1.29-0-virt"},"platform": "CPython 3.9.17.final.0"}}, returnFieldsSelector: }'
- requests:
- - header:
- length: 262
- requestId: 1890541915
- responseTo: 0
- Opcode: 2004
- message:
- flags: 0
- collection_name: admin.$cmd
- number_to_skip: 0
- number_to_return: -1
- query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.4.1"},"os":{"type":"Linux","name":"Linux","architecture":"aarch64","version":"6.1.29-0-virt"},"platform":"CPython 3.9.17.final.0"}}'
- return_fields_selector: ""
- read_delay: 82208
- responses:
- - header:
- length: 329
- requestId: 3
- responseTo: 1890541915
- Opcode: 1
- message:
- response_flags: 8
- cursor_id: 0
- starting_from: 0
- number_returned: 1
- documents:
- - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190448932"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
- read_delay: 659750
- created: 1692190448
----
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: config
-spec:
- metadata:
- operation: '{ OpQuery flags: [], fullCollectionName: admin.$cmd, numberToSkip: 0, numberToReturn: -1, query: {"ismaster": {"$numberInt":"1"},"helloOk": true,"client": {"driver": {"name": "PyMongo","version": "4.4.1"},"os": {"type": "Linux","name": "Linux","architecture": "aarch64","version": "6.1.29-0-virt"},"platform": "CPython 3.9.17.final.0"},"compression": []}, returnFieldsSelector: }'
- requests:
- - header:
- length: 280
- requestId: 1076681270
- responseTo: 0
- Opcode: 2004
- message:
- flags: 0
- collection_name: admin.$cmd
- number_to_skip: 0
- number_to_return: -1
- query: '{"ismaster":{"$numberInt":"1"},"helloOk":true,"client":{"driver":{"name":"PyMongo","version":"4.4.1"},"os":{"type":"Linux","name":"Linux","architecture":"aarch64","version":"6.1.29-0-virt"},"platform":"CPython 3.9.17.final.0"},"compression":[]}'
- return_fields_selector: ""
- read_delay: 51917
- responses:
- - header:
- length: 329
- requestId: 4
- responseTo: 1076681270
- Opcode: 1
- message:
- response_flags: 8
- cursor_id: 0
- starting_from: 0
- number_returned: 1
- documents:
- - '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190448936"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"2"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
- read_delay: 999250
- created: 1692190448
----
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: config
-spec:
- metadata:
- operation: '{ OpMsg flags: 65536, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }], checksum: 0 }'
- requests:
- - header:
- length: 134
- requestId: 613273587
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 65536
- sections:
- - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxAwaitTimeMS":{"$numberInt":"10000"},"$db":"admin"} }'
- checksum: 0
- read_delay: 3336333
- responses:
- - header:
- length: 313
- requestId: 10
- responseTo: 613273587
- Opcode: 2013
- message:
- flagBits: 2
- sections:
- - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190458940"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 10005077213
- created: 1692190458
----
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: config
-spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }], checksum: 0 }'
- requests:
- - header:
- length: 52
- requestId: 1075693109
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"hello":{"$numberInt":"1"},"$db":"admin"} }'
- checksum: 0
- read_delay: 10043184088
- responses:
- - header:
- length: 313
- requestId: 11
- responseTo: 1075693109
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"isWritablePrimary":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190458982"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 746417
- created: 1692190458
----
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: config
-spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }], checksum: 0 }'
- requests:
- - header:
- length: 65
- requestId: 1299455543
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"ismaster":{"$numberInt":"1"},"helloOk":true,"$db":"admin"} }'
- checksum: 0
- read_delay: 10042282047
- responses:
- - header:
- length: 314
- requestId: 15
- responseTo: 1299455543
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"64dcc6eb86233da4f389a58b"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1692190469027"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"3"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"17"},"readOnly":false,"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 1815417
- created: 1692190469
diff --git a/flask-mongo/keploy/test-set-1/mocks.yaml b/flask-mongo/keploy/test-set-1/mocks.yaml
deleted file mode 100755
index 3051236..0000000
--- a/flask-mongo/keploy/test-set-1/mocks.yaml
+++ /dev/null
@@ -1,64 +0,0 @@
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: mocks
-spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"insert":"students","ordered":true,"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }, { SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"64dcc6f03b29d5de7bb2ae07"},"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}} ] }], checksum: 0 }'
- requests:
- - header:
- length: 197
- requestId: 1340074696
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"insert":"students","ordered":true,"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }'
- - '{ SectionSingle identifier: documents , msgs: [ {"_id":{"$oid":"64dcc6f03b29d5de7bb2ae07"},"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}} ] }'
- checksum: 0
- read_delay: 566167
- responses:
- - header:
- length: 45
- requestId: 6
- responseTo: 1340074696
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"n":{"$numberInt":"1"},"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 27458
- created: 1692190448
----
-version: api.keploy.io/v1beta2
-kind: Mongo
-name: mocks
-spec:
- metadata:
- operation: '{ OpMsg flags: 0, sections: [{ SectionSingle msg: {"find":"students","filter":{},"projection":{"_id":{"$numberInt":"0"}},"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }], checksum: 0 }'
- requests:
- - header:
- length: 140
- requestId: 1596327406
- responseTo: 0
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"find":"students","filter":{},"projection":{"_id":{"$numberInt":"0"}},"lsid":{"id":{"$binary":{"base64":"HHvg4XLYQFWra6WjBn1j/A==","subType":"04"}}},"$db":"studentsdb"} }'
- checksum: 0
- read_delay: 9681533921
- responses:
- - header:
- length: 273
- requestId: 9
- responseTo: 1596327406
- Opcode: 2013
- message:
- flagBits: 0
- sections:
- - '{ SectionSingle msg: {"cursor":{"firstBatch":[{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}},{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}},{"student_id":"123","name":"Sarthak","age":{"$numberInt":"20"}}],"id":{"$numberLong":"0"},"ns":"studentsdb.students"},"ok":{"$numberDouble":"1.0"}} }'
- checksum: 0
- read_delay: 40167
- created: 1692190458
diff --git a/flask-mongo/keploy/test-set-1/test-1.yaml b/flask-mongo/keploy/test-set-1/test-1.yaml
deleted file mode 100755
index 4141f28..0000000
--- a/flask-mongo/keploy/test-set-1/test-1.yaml
+++ /dev/null
@@ -1,38 +0,0 @@
-version: api.keploy.io/v1beta2
-kind: Http
-name: test-1
-spec:
- metadata: {}
- req:
- method: POST
- proto_major: 1
- proto_minor: 1
- url: http://localhost:6000/students
- header:
- Accept: '*/*'
- Content-Length: "51"
- Content-Type: application/json
- Host: localhost:6000
- User-Agent: curl/7.77.0
- body: '{"student_id": "123", "name": "Sarthak", "age": 20}'
- body_type: ""
- resp:
- status_code: 200
- header:
- Content-Length: "48"
- Content-Type: application/json
- Date: Wed, 16 Aug 2023 12:54:08 GMT
- Server: Werkzeug/2.3.7 Python/3.9.17
- body: |
- {
- "message": "Student created successfully"
- }
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- objects: []
- assertions:
- noise:
- - header.Date
- created: 1692190448
diff --git a/flask-mongo/keploy/test-set-1/test-2.yaml b/flask-mongo/keploy/test-set-1/test-2.yaml
deleted file mode 100755
index 77cb4a3..0000000
--- a/flask-mongo/keploy/test-set-1/test-2.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-version: api.keploy.io/v1beta2
-kind: Http
-name: test-2
-spec:
- metadata: {}
- req:
- method: GET
- proto_major: 1
- proto_minor: 1
- url: http://localhost:6000/students
- header:
- Accept: '*/*'
- Host: localhost:6000
- User-Agent: curl/7.77.0
- body: ""
- body_type: ""
- resp:
- status_code: 200
- header:
- Content-Length: "224"
- Content-Type: application/json
- Date: Wed, 16 Aug 2023 12:54:18 GMT
- Server: Werkzeug/2.3.7 Python/3.9.17
- body: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n"
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- objects: []
- assertions:
- noise:
- - header.Date
- - body.name
- created: 1692190458
diff --git a/flask-mongo/keploy/testReports/report-1.yaml b/flask-mongo/keploy/testReports/report-1.yaml
deleted file mode 100755
index 14623ce..0000000
--- a/flask-mongo/keploy/testReports/report-1.yaml
+++ /dev/null
@@ -1,181 +0,0 @@
-version: api.keploy.io/v1beta1
-name: report-1
-status: PASSED
-success: 2
-failure: 0
-total: 2
-tests:
- - kind: Http
- name: report-1
- status: PASSED
- started: 1692258836
- completed: 1692258836
- test_case_path: /files/keploy
- mock_path: ""
- test_case_id: test-1
- req:
- method: POST
- proto_major: 1
- proto_minor: 1
- url: http://172.19.0.4:6000/students
- header:
- Accept: '*/*'
- Content-Length: "51"
- Content-Type: application/json
- Host: localhost:6000
- User-Agent: curl/7.77.0
- body: '{"student_id": "123", "name": "Sarthak", "age": 20}'
- body_type: ""
- resp:
- status_code: 200
- header:
- Content-Length: "48"
- Content-Type: application/json
- Date: Wed, 16 Aug 2023 12:54:08 GMT
- Server: Werkzeug/2.3.7 Python/3.9.17
- body: |
- {
- "message": "Student created successfully"
- }
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- noise:
- - header.Date
- result:
- status_code:
- normal: true
- expected: 200
- actual: 200
- headers_result:
- - normal: true
- expected:
- key: Server
- value:
- - Werkzeug/2.3.7 Python/3.9.17
- actual:
- key: Server
- value:
- - Werkzeug/2.3.7 Python/3.9.17
- - normal: true
- expected:
- key: Content-Length
- value:
- - "48"
- actual:
- key: Content-Length
- value:
- - "48"
- - normal: true
- expected:
- key: Content-Type
- value:
- - application/json
- actual:
- key: Content-Type
- value:
- - application/json
- - normal: true
- expected:
- key: Date
- value:
- - Wed, 16 Aug 2023 12:54:08 GMT
- actual:
- key: Date
- value:
- - Thu, 17 Aug 2023 07:53:56 GMT
- body_result:
- - normal: true
- type: JSON
- expected: |
- {
- "message": "Student created successfully"
- }
- actual: |
- {
- "message": "Student created successfully"
- }
- dep_result: []
- - kind: Http
- name: report-1
- status: PASSED
- started: 1692258836
- completed: 1692258836
- test_case_path: /files/keploy
- mock_path: ""
- test_case_id: test-2
- req:
- method: GET
- proto_major: 1
- proto_minor: 1
- url: http://172.19.0.4:6000/students
- header:
- Accept: '*/*'
- Host: localhost:6000
- User-Agent: curl/7.77.0
- body: ""
- body_type: ""
- resp:
- status_code: 200
- header:
- Content-Length: "224"
- Content-Type: application/json
- Date: Wed, 16 Aug 2023 12:54:18 GMT
- Server: Werkzeug/2.3.7 Python/3.9.17
- body: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n"
- body_type: ""
- status_message: ""
- proto_major: 0
- proto_minor: 0
- noise:
- - header.Date
- - body.name
- result:
- status_code:
- normal: true
- expected: 200
- actual: 200
- headers_result:
- - normal: true
- expected:
- key: Date
- value:
- - Wed, 16 Aug 2023 12:54:18 GMT
- actual:
- key: Date
- value:
- - Thu, 17 Aug 2023 07:53:56 GMT
- - normal: true
- expected:
- key: Server
- value:
- - Werkzeug/2.3.7 Python/3.9.17
- actual:
- key: Server
- value:
- - Werkzeug/2.3.7 Python/3.9.17
- - normal: true
- expected:
- key: Content-Length
- value:
- - "224"
- actual:
- key: Content-Length
- value:
- - "224"
- - normal: true
- expected:
- key: Content-Type
- value:
- - application/json
- actual:
- key: Content-Type
- value:
- - application/json
- body_result:
- - normal: true
- type: JSON
- expected: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n"
- actual: "[\n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }, \n {\n \"age\": 20, \n \"name\": \"Sarthak\", \n \"student_id\": \"123\"\n }\n]\n"
- dep_result: []
diff --git a/flask-mongo/postman_tests/delete.js b/flask-mongo/postman_tests/delete.js
new file mode 100644
index 0000000..a2e8f13
--- /dev/null
+++ b/flask-mongo/postman_tests/delete.js
@@ -0,0 +1,17 @@
+pm.test("Status code is 200 or 404", function () {
+ pm.expect(pm.response.code).to.be.oneOf([200, 404]);
+});
+
+pm.test("Successful deletion response message", function () {
+ if (pm.response.code === 200) {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.message).to.eql("Task deleted successfully");
+ }
+});
+
+pm.test("Task not found", function () {
+ if (pm.response.code === 404) {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.error).to.eql("Task not found");
+ }
+});
diff --git a/flask-mongo/postman_tests/get.js b/flask-mongo/postman_tests/get.js
new file mode 100644
index 0000000..74b758a
--- /dev/null
+++ b/flask-mongo/postman_tests/get.js
@@ -0,0 +1,17 @@
+pm.test("Status code is 200", function () {
+ pm.response.to.have.status(200);
+});
+
+pm.test("Response is an array", function () {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.tasks).to.be.an("array");
+});
+
+pm.test("Each task has an id, title, and description", function () {
+ var jsonData = pm.response.json();
+ jsonData.tasks.forEach(function (task) {
+ pm.expect(task).to.have.property("id");
+ pm.expect(task).to.have.property("title");
+ pm.expect(task).to.have.property("description");
+ });
+});
diff --git a/flask-mongo/postman_tests/post.js b/flask-mongo/postman_tests/post.js
new file mode 100644
index 0000000..9efeeb8
--- /dev/null
+++ b/flask-mongo/postman_tests/post.js
@@ -0,0 +1,14 @@
+pm.test("Status code is 201", function () {
+ pm.response.to.have.status(201);
+});
+
+pm.test("Response contains task ID", function () {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData).to.have.property("id");
+ pm.expect(jsonData.id).to.not.be.empty;
+});
+
+pm.test("Response message is correct", function () {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.message).to.eql("Task created successfully");
+});
diff --git a/flask-mongo/postman_tests/put.js b/flask-mongo/postman_tests/put.js
new file mode 100644
index 0000000..d8af377
--- /dev/null
+++ b/flask-mongo/postman_tests/put.js
@@ -0,0 +1,17 @@
+pm.test("Status code is 200 or 404", function () {
+ pm.expect(pm.response.code).to.be.oneOf([200, 404]);
+});
+
+pm.test("Successful update response message", function () {
+ if (pm.response.code === 200) {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.message).to.eql("Task updated successfully");
+ }
+});
+
+pm.test("Task not found or no changes made", function () {
+ if (pm.response.code === 404) {
+ var jsonData = pm.response.json();
+ pm.expect(jsonData.error).to.eql("Task not found or no changes were made");
+ }
+});
diff --git a/flask-mongo/requirements.txt b/flask-mongo/requirements.txt
index 7a03746..324ca18 100644
--- a/flask-mongo/requirements.txt
+++ b/flask-mongo/requirements.txt
@@ -1,4 +1,6 @@
-Flask
-pymongo==4.4.1
-Flask-Cors==3.0.10
-Werkzeug==2.2.2
\ No newline at end of file
+Flask==3.0.3
+Flask-Cors==4.0.0
+pymongo==4.6.3
+coverage==7.4.4
+bson==0.5.10
+keploy==2.0.0a33
\ No newline at end of file
diff --git a/flask-mongo/test_app.py b/flask-mongo/test_app.py
new file mode 100644
index 0000000..30cf13f
--- /dev/null
+++ b/flask-mongo/test_app.py
@@ -0,0 +1,45 @@
+import unittest
+from app import app
+from unittest.mock import patch, MagicMock
+import json
+from bson import ObjectId
+
+class TestTaskManager(unittest.TestCase):
+
+ def setUp(self):
+ self.app = app.test_client()
+ self.app.testing = True
+
+ self.collection_mock = MagicMock()
+ self.patcher = patch('app.collection', self.collection_mock)
+ self.patcher.start()
+
+ def tearDown(self):
+ self.patcher.stop()
+
+ def test_create_task(self):
+ data = {'title': 'Test Task', 'description': 'This is a test task'}
+ response = self.app.post('/api/tasks', json=data)
+ self.assertEqual(response.status_code, 201)
+ self.assertIn(b'Task created successfully', response.data)
+
+ def test_get_all_tasks(self):
+ self.collection_mock.find.return_value = []
+ response = self.app.get('/api/tasks')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(json.loads(response.data)['tasks'], [])
+
+ def test_update_task(self):
+ with patch('app.ObjectId', return_value='mocked_id'):
+ response = self.app.put('/api/tasks/mock_id', json={'title': 'Updated Task', 'description': 'This is an updated task'})
+ self.assertEqual(response.status_code, 200)
+ self.assertIn(b'Task updated successfully', response.data)
+
+ def test_delete_task(self):
+ with patch('app.ObjectId', return_value=ObjectId()):
+ response = self.app.delete('/api/tasks/mock_id')
+ self.assertEqual(response.status_code, 200)
+ self.assertIn(b'Task deleted successfully', response.data)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/flask-mongo/test_keploy.py b/flask-mongo/test_keploy.py
new file mode 100644
index 0000000..4ee126a
--- /dev/null
+++ b/flask-mongo/test_keploy.py
@@ -0,0 +1,8 @@
+from keploy import run, RunOptions
+
+def test_keploy():
+ try:
+ options = RunOptions(delay=15, debug=False, port=0)
+ except ValueError as e:
+ print(e)
+ run("python3 -m coverage run -p --data-file=.coverage.keploy app.py", options)
\ No newline at end of file