MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_request_response

Function test_request_response

tests/tests/test_timeline.py:155–239  ·  view source on GitHub ↗
(make_timeline, outcome)

Source from the content-addressed store, hash-verified

153
154@pytest.mark.parametrize("outcome", ["success", "failure"])
155def test_request_response(make_timeline, outcome):
156 timeline, initial_history = make_timeline()
157 messages = MessageFactory()
158
159 request_msg = messages.request("next", {"threadId": 3})
160 request_exp = expectation_of(request_msg)
161 request = timeline.record_request(request_msg)
162
163 assert request == request_exp
164 assert request.command == request_msg.command
165 assert request.arguments == request_msg.arguments
166 assert request.circumstances == (
167 "request",
168 request_msg.command,
169 request_msg.arguments,
170 )
171
172 with timeline.frozen():
173 assert timeline.last is request
174 assert timeline.history() == initial_history + [some.object.same_as(request)]
175 timeline.expect_realized(request_exp)
176 timeline.expect_realized(Request("next"))
177
178 response_msg = messages.response(
179 request_msg, {} if outcome == "success" else Exception("error!")
180 )
181 response = timeline.record_response(request, response_msg)
182 assert response.request is request
183 assert response.body == response_msg.body
184 if outcome == "success":
185 assert response.success
186 else:
187 assert not response.success
188 assert response.circumstances == ("response", request, response_msg.body)
189
190 assert response == Response(request, response_msg.body)
191 assert response == Response(request, some.object)
192 assert response == Response(request)
193
194 if outcome == "success":
195 assert response == Response(request, some.dict)
196 assert response != Response(request, some.error)
197 else:
198 assert response != Response(request, some.dict)
199 assert response == Response(request, some.error)
200
201 assert response == Response(request_exp, response_msg.body)
202 assert response == Response(request_exp, some.object)
203 assert response == Response(request_exp)
204
205 if outcome == "success":
206 assert response == Response(request_exp, some.dict)
207 assert response != Response(request_exp, some.error)
208 else:
209 assert response != Response(request_exp, some.dict)
210 assert response == Response(request_exp, some.error)
211
212 with timeline.frozen():

Callers

nothing calls this directly

Calls 13

RequestFunction · 0.90
ResponseFunction · 0.90
make_timelineFunction · 0.85
MessageFactoryClass · 0.85
expectation_ofFunction · 0.85
record_requestMethod · 0.80
frozenMethod · 0.80
historyMethod · 0.80
same_asMethod · 0.80
expect_realizedMethod · 0.80
record_responseMethod · 0.80
expect_not_realizedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…