Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 75 additions & 94 deletions versioned_docs/version-2.0.0/quickstart/python-flask-mongo.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,72 +93,53 @@ 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`.

```yaml
# Generated by Keploy (2.4.16)
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
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:6000/students
header:
Accept: '*/*'
Content-Length: "54"
Content-Type: application/json
Host: localhost:6000
User-Agent: curl/8.7.1
body: '{"student_id": "12345", "name": "John Doe", "age": 20}'
timestamp: 2025-04-02T13:12:05.255523333Z
resp:
status_code: 200
header:
Content-Length: "48"
Content-Type: application/json
Date: Wed, 02 Apr 2025 13:12:05 GMT
Server: Werkzeug/2.2.2 Python/3.9.21
body: |
{
"message": "Student created successfully"
}
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2025-04-02T13:12:07.292707847Z
objects: []
assertions:
noise:
header.Date: []
created: 1743599527
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"}'
curl --request POST \
--url http://localhost:6000/students \
--header 'Host: localhost:6000' \
--header 'User-Agent: curl/8.7.1' \
--header 'Accept: */*' \
--header 'Content-Type: application/json' \
--data "{\"student_id\": \"12345\", \"name\": \"John Doe\", \"age\": 20}"
```

This is how the `mocks.yml` looks like:
Expand All @@ -168,39 +149,39 @@ 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
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.0-32-cloud-arm64"},"platform": "CPython 3.9.21.final.0"}}, returnFieldsSelector: }'
type: config
requests:
- header:
length: 269
requestId: 846930886
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.0-32-cloud-arm64"},"platform":"CPython 3.9.21.final.0"}}'
return_fields_selector: ""
responses:
- header:
length: 329
requestId: 3
responseTo: 846930886
Opcode: 1
message:
response_flags: 8
cursor_id: 0
starting_from: 0
number_returned: 1
documents:
- '{"helloOk":true,"ismaster":true,"topologyVersion":{"processId":{"$oid":"67ed3773a2f7dd8385defa99"},"counter":{"$numberLong":"0"}},"maxBsonObjectSize":{"$numberInt":"16777216"},"maxMessageSizeBytes":{"$numberInt":"48000000"},"maxWriteBatchSize":{"$numberInt":"100000"},"localTime":{"$date":{"$numberLong":"1743599485435"}},"logicalSessionTimeoutMinutes":{"$numberInt":"30"},"connectionId":{"$numberInt":"1"},"minWireVersion":{"$numberInt":"0"},"maxWireVersion":{"$numberInt":"25"},"readOnly":false,"ok":{"$numberDouble":"1.0"}}'
read_delay: 990489
created: 1743599485
reqTimestampMock: 2025-04-02T13:11:25.434864042Z
resTimestampMock: 2025-04-02T13:11:25.436114528Z
```

Want to see if everything works as expected?
Expand Down
Loading