@@ -93,72 +93,53 @@ curl -X DELETE http://localhost:6000/students/12345
9393And 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 ` .
9494
9595``` yaml
96+ # Generated by Keploy (2.4.16)
9697version : api.keploy.io/v1beta1
9798kind : Http
9899name : test-1
99100spec :
100- metadata : {}
101- req :
102- method : GET
103- proto_major : 1
104- proto_minor : 1
105- url : http://localhost:5000/api/tasks
106- header :
107- Accept : " */*"
108- Accept-Encoding : gzip, deflate, br
109- Cache-Control : no-cache
110- Connection : keep-alive
111- Content-Length : " 59"
112- Content-Type : application/json
113- Host : localhost:5000
114- Postman-Token : 10512b5c-4da7-4ef3-b145-101cdd1357f1
115- User-Agent : PostmanRuntime/7.32.1
116- body : ' {"title": "Task 6","description": "Description for Task 6"}'
117- timestamp : 2024-04-22T16:38:39.232565209+05:30
118- resp :
119- status_code : 200
120- header :
121- Access-Control-Allow-Origin : " *"
122- Content-Length : " 267"
123- Content-Type : application/json
124- Date : Mon, 22 Apr 2024 11:08:39 GMT
125- Server : Werkzeug/3.0.2 Python/3.10.12
126- body : |
127- {
128- "tasks": [
129- {
130- "description": "should update",
131- "id": "6626362fc7c5eddf174c88e4",
132- "title": "Updated"
133- },
134- {
135- "description": "Should work",
136- "id": "66263667c7c5eddf174c88e5",
137- "title": "Let's Check another time"
138- }
139- ]
140- }
141- status_message : OK
142- proto_major : 0
143- proto_minor : 0
144- timestamp : 2024-04-22T16:38:41.245704918+05:30
145- objects : []
146- assertions :
147- noise :
148- header.Date : []
149- created : 1713784121
101+ metadata : {}
102+ req :
103+ method : POST
104+ proto_major : 1
105+ proto_minor : 1
106+ url : http://localhost:6000/students
107+ header :
108+ Accept : ' */*'
109+ Content-Length : " 54"
110+ Content-Type : application/json
111+ Host : localhost:6000
112+ User-Agent : curl/8.7.1
113+ body : ' {"student_id": "12345", "name": "John Doe", "age": 20}'
114+ timestamp : 2025-04-02T13:12:05.255523333Z
115+ resp :
116+ status_code : 200
117+ header :
118+ Content-Length : " 48"
119+ Content-Type : application/json
120+ Date : Wed, 02 Apr 2025 13:12:05 GMT
121+ Server : Werkzeug/2.2.2 Python/3.9.21
122+ body : |
123+ {
124+ "message": "Student created successfully"
125+ }
126+ status_message : OK
127+ proto_major : 0
128+ proto_minor : 0
129+ timestamp : 2025-04-02T13:12:07.292707847Z
130+ objects : []
131+ assertions :
132+ noise :
133+ header.Date : []
134+ created : 1743599527
150135curl : |-
151- curl --request GET \
152- --url http://localhost:5000/api/tasks \
153- --header 'Host: localhost:5000' \
154- --header 'User-Agent: PostmanRuntime/7.32.1' \
155- --header 'Accept: */*' \
156- --header 'Content-Type: application/json' \
157- --header 'Connection: keep-alive' \
158- --header 'Cache-Control: no-cache' \
159- --header 'Postman-Token: 10512b5c-4da7-4ef3-b145-101cdd1357f1' \
160- --header 'Accept-Encoding: gzip, deflate, br' \
161- --data '{"title": "Task 6","description": "Description for Task 6"}'
136+ curl --request POST \
137+ --url http://localhost:6000/students \
138+ --header 'Host: localhost:6000' \
139+ --header 'User-Agent: curl/8.7.1' \
140+ --header 'Accept: */*' \
141+ --header 'Content-Type: application/json' \
142+ --data "{\"student_id\": \"12345\", \"name\": \"John Doe\", \"age\": 20}"
162143` ` `
163144
164145This is how the ` mocks.yml` looks like:
@@ -168,39 +149,39 @@ version: api.keploy.io/v1beta1
168149kind: Mongo
169150name: mock-0
170151spec:
171- metadata:
172- 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: }'
173- type: config
174- requests:
175- - header:
176- length: 283
177- requestId: 1804289383
178- responseTo: 0
179- Opcode: 2004
180- message:
181- flags: 0
182- collection_name: admin.$cmd
183- number_to_skip: 0
184- number_to_return: -1
185- 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"}}'
186- return_fields_selector: ""
187- responses:
188- - header:
189- length: 329
190- requestId: 238
191- responseTo: 1804289383
192- Opcode: 1
193- message:
194- response_flags: 8
195- cursor_id: 0
196- starting_from: 0
197- number_returned: 1
198- documents:
199- - '{"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"}}'
200- read_delay: 1010011
201- created: 1713784113
202- reqTimestampMock: 2024 -04-22T16:38:33.762559618+05:30
203- resTimestampMock: 2024 -04-22T16:38:33.763749062+05:30
152+ metadata:
153+ 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: }'
154+ type: config
155+ requests:
156+ - header:
157+ length: 269
158+ requestId: 846930886
159+ responseTo: 0
160+ Opcode: 2004
161+ message:
162+ flags: 0
163+ collection_name: admin.$cmd
164+ number_to_skip: 0
165+ number_to_return: -1
166+ 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"}}'
167+ return_fields_selector: ""
168+ responses:
169+ - header:
170+ length: 329
171+ requestId: 3
172+ responseTo: 846930886
173+ Opcode: 1
174+ message:
175+ response_flags: 8
176+ cursor_id: 0
177+ starting_from: 0
178+ number_returned: 1
179+ documents:
180+ - '{"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"}}'
181+ read_delay: 990489
182+ created: 1743599485
183+ reqTimestampMock: 2025 -04-02T13:11:25.434864042Z
184+ resTimestampMock: 2025 -04-02T13:11:25.436114528Z
204185` ` `
205186
206187Want to see if everything works as expected?
0 commit comments