Skip to content

Commit eee87e0

Browse files
Achanandhi-MAchanandhiSonichigonehagup
authored andcommitted
chore: update Flask-Mongo quickstart to fix Docker issues (#510)
* fixed:flask-mongo-quickstart * chore: update flask mongo tests docs (#509) * fixed:flask-mongo-quickstart Signed-off-by: Achanandhi <[email protected]> * chore: update flask mongo test Signed-off-by: Achanandhi <[email protected]> Signed-off-by: Achanandhi <[email protected]> --------- Signed-off-by: Achanandhi <[email protected]> Signed-off-by: Achanandhi <[email protected]> Co-authored-by: Achanandhi <[email protected]> Co-authored-by: Animesh Pathak <[email protected]> * chore: quickstart python flaskmongo docker-issues Signed-off-by: Achanandhi <[email protected]> --------- Signed-off-by: Achanandhi <[email protected]> Signed-off-by: Achanandhi <[email protected]> Co-authored-by: Achanandhi <[email protected]> Co-authored-by: Animesh Pathak <[email protected]> Co-authored-by: Neha Gupta <[email protected]>
1 parent 5cd284c commit eee87e0

File tree

1 file changed

+33
-53
lines changed

1 file changed

+33
-53
lines changed

versioned_docs/version-2.0.0/quickstart/python-flask-mongo.md

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,25 @@ Now, your app will start running, and you have to make some API calls to generat
233233
1. **Make a POST request:**
234234

235235
```bash
236-
curl -X POST -H "Content-Type: application/json" -d '{"title":"Task 1","description":"Important task"}' http://localhost:5000/api/tasks
236+
curl -X POST -H "Content-Type: application/json" -d '{"student_id": "12345", "name": "John Doe", "age": 20}' http://localhost:6000/students
237237
```
238238

239239
2. **Make a GET request:**
240240

241241
```bash
242-
curl http://localhost:5000/api/tasks
242+
curl http://localhost:6000/students
243243
```
244244

245245
3. **Make a PUT request:**
246246

247247
```bash
248-
curl -X PUT -H "Content-Type: application/json" -d '{"title":"Task 1","description":"Random task"}' http://localhost:5000/api/tasks/12345
248+
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Jane Smith", "age": 21}' http://localhost:6000/students/12345
249249
```
250250

251251
4. **Make a DELETE request:**
252252

253253
```bash
254-
curl -X DELETE http://localhost:5000/api/tasks/12345
254+
curl -X DELETE http://localhost:6000/students/12345
255255
```
256256

257257
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`.
@@ -263,66 +263,46 @@ name: test-1
263263
spec:
264264
metadata: {}
265265
req:
266-
method: GET
266+
method: POST
267267
proto_major: 1
268268
proto_minor: 1
269-
url: http://localhost:5000/api/tasks
269+
url: http://localhost:6000/students
270270
header:
271271
Accept: "*/*"
272-
Accept-Encoding: gzip, deflate, br
273-
Cache-Control: no-cache
274-
Connection: keep-alive
275-
Content-Length: "59"
272+
Content-Length: "54"
276273
Content-Type: application/json
277-
Host: localhost:5000
278-
Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1
279-
User-Agent: PostmanRuntime/7.32.1
280-
body: '{"title": "Task 6","description": "Description for Task 6"}'
281-
timestamp: 2024-04-22T16:38:39.232565209+05:30
274+
Host: localhost:6000
275+
User-Agent: curl/8.7.1
276+
body: '{"student_id": "12345", "name": "John Doe", "age": 20}'
277+
timestamp: 2025-04-02T13:12:05.255523333Z
282278
resp:
283279
status_code: 200
284280
header:
285-
Access-Control-Allow-Origin: "*"
286-
Content-Length: "267"
281+
Content-Length: "48"
287282
Content-Type: application/json
288-
Date: Mon, 22 Apr 2024 11:08:39 GMT
289-
Server: Werkzeug/3.0.2 Python/3.10.12
283+
Date: Wed, 02 Apr 2025 13:12:05 GMT
284+
Server: Werkzeug/2.2.2 Python/3.9.21
290285
body: |
291286
{
292-
"tasks": [
293-
{
294-
"description": "should update",
295-
"id": "6626362fc7c5eddf174c88e4",
296-
"title": "Updated"
297-
},
298-
{
299-
"description": "Should work",
300-
"id": "66263667c7c5eddf174c88e5",
301-
"title": "Let's Check another time"
302-
}
303-
]
287+
"message": "Student created successfully"
304288
}
305289
status_message: OK
306290
proto_major: 0
307291
proto_minor: 0
308-
timestamp: 2024-04-22T16:38:41.245704918+05:30
292+
timestamp: 2025-04-02T13:12:07.292707847Z
309293
objects: []
310294
assertions:
311295
noise:
312296
header.Date: []
313-
created: 1713784121
297+
created: 1743599527
314298
curl: |-
315-
curl --request GET \
316-
--url http://localhost:5000/api/tasks \
317-
--header 'Host: localhost:5000' \
318-
--header 'User-Agent: PostmanRuntime/7.32.1' \
299+
curl --request POST \
300+
--url http://localhost:6000/students \
301+
--header 'Host: localhost:6000' \
302+
--header 'User-Agent: curl/8.7.1' \
319303
--header 'Accept: */*' \
320304
--header 'Content-Type: application/json' \
321-
--header 'Connection: keep-alive' \
322-
--header 'Cache-Control: no-cache' \
323-
--header 'Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1' \
324-
--header 'Accept-Encoding: gzip, deflate, br' \
325-
--data '{"title": "Task 6","description": "Description for Task 6"}'
305+
--data "{\"student_id\": \"12345\", \"name\": \"John Doe\", \"age\": 20}"
326306
```
327307

328308
This is how the `mocks.yml` looks like:
@@ -333,38 +313,38 @@ kind: Mongo
333313
name: mock-0
334314
spec:
335315
metadata:
336-
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: }'
316+
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: }'
337317
type: config
338318
requests:
339319
- header:
340-
length: 283
341-
requestId: 1804289383
320+
length: 269
321+
requestId: 846930886
342322
responseTo: 0
343323
Opcode: 2004
344324
message:
345325
flags: 0
346326
collection_name: admin.$cmd
347327
number_to_skip: 0
348328
number_to_return: -1
349-
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"}}'
329+
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"}}'
350330
return_fields_selector: ""
351331
responses:
352332
- header:
353333
length: 329
354-
requestId: 238
355-
responseTo: 1804289383
334+
requestId: 3
335+
responseTo: 846930886
356336
Opcode: 1
357337
message:
358338
response_flags: 8
359339
cursor_id: 0
360340
starting_from: 0
361341
number_returned: 1
362342
documents:
363-
- '{"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"}}'
364-
read_delay: 1010011
365-
created: 1713784113
366-
reqTimestampMock: 2024-04-22T16:38:33.762559618+05:30
367-
resTimestampMock: 2024-04-22T16:38:33.763749062+05:30
343+
- '{"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"}}'
344+
read_delay: 990489
345+
created: 1743599485
346+
reqTimestampMock: 2025-04-02T13:11:25.434864042Z
347+
resTimestampMock: 2025-04-02T13:11:25.436114528Z
368348
```
369349

370350
## Run the tests

0 commit comments

Comments
 (0)