Test that we can kill individual streams.
(tctx)
| 1007 | |
| 1008 | |
| 1009 | def test_kill_stream(tctx): |
| 1010 | """Test that we can kill individual streams.""" |
| 1011 | playbook, cff = start_h2_client(tctx) |
| 1012 | flow1 = Placeholder(HTTPFlow) |
| 1013 | flow2 = Placeholder(HTTPFlow) |
| 1014 | |
| 1015 | req_headers_hook_1 = http.HttpRequestHeadersHook(flow1) |
| 1016 | |
| 1017 | def kill(flow: HTTPFlow): |
| 1018 | # Can't use flow.kill() here because that currently still depends on a reply object. |
| 1019 | flow.error = Error(Error.KILLED_MESSAGE) |
| 1020 | |
| 1021 | server = Placeholder(Server) |
| 1022 | data_req1 = Placeholder(bytes) |
| 1023 | |
| 1024 | assert ( |
| 1025 | playbook |
| 1026 | >> DataReceived( |
| 1027 | tctx.client, |
| 1028 | cff.build_headers_frame( |
| 1029 | example_request_headers, flags=["END_STREAM"], stream_id=1 |
| 1030 | ).serialize() |
| 1031 | + cff.build_headers_frame( |
| 1032 | example_request_headers, flags=["END_STREAM"], stream_id=3 |
| 1033 | ).serialize(), |
| 1034 | ) |
| 1035 | << req_headers_hook_1 |
| 1036 | << http.HttpRequestHeadersHook(flow2) |
| 1037 | >> reply(side_effect=kill) |
| 1038 | << http.HttpErrorHook(flow2) |
| 1039 | >> reply() |
| 1040 | << SendData( |
| 1041 | tctx.client, |
| 1042 | cff.build_rst_stream_frame( |
| 1043 | 3, error_code=ErrorCodes.INTERNAL_ERROR |
| 1044 | ).serialize(), |
| 1045 | ) |
| 1046 | >> reply(to=req_headers_hook_1) |
| 1047 | << http.HttpRequestHook(flow1) |
| 1048 | >> reply() |
| 1049 | << OpenConnection(server) |
| 1050 | >> reply(None, side_effect=make_h2) |
| 1051 | << SendData(server, data_req1) |
| 1052 | ) |
| 1053 | frames = decode_frames(data_req1()) |
| 1054 | assert [type(x) for x in frames] == [ |
| 1055 | hyperframe.frame.SettingsFrame, |
| 1056 | hyperframe.frame.WindowUpdateFrame, |
| 1057 | hyperframe.frame.HeadersFrame, |
| 1058 | ] |
| 1059 | |
| 1060 | |
| 1061 | class TestClient: |
nothing calls this directly
no test coverage detected
searching dependent graphs…