Skip to content
Snippets Groups Projects
Commit 8b223e29 authored by Nathaniel Manista's avatar Nathaniel Manista
Browse files

Correct Python cancel_after_begin interop test

It was a mistake that requests might be sent; the test specification
calls for no requests to be sent. It was a mistake that the response
future's cancelled() method was called; the cancelled() method returns
something more like "was this object's cancel() method called earlier?"
than "did the RPC terminate with status code CANCELLED?". Since it's
something that we'd well enough like to work I've retained the
cancelled() call with a different failure message.
parent edcd4916
No related branches found
No related tags found
No related merge requests found
...@@ -159,16 +159,6 @@ def _server_streaming(stub): ...@@ -159,16 +159,6 @@ def _server_streaming(stub):
raise ValueError( raise ValueError(
'response body of invalid size %d!' % len(response.payload.body)) 'response body of invalid size %d!' % len(response.payload.body))
def _cancel_after_begin(stub):
sizes = (27182, 8, 1828, 45904,)
payloads = (messages_pb2.Payload(body=b'\x00' * size) for size in sizes)
requests = (messages_pb2.StreamingInputCallRequest(payload=payload)
for payload in payloads)
response_future = stub.StreamingInputCall.future(requests)
response_future.cancel()
if not response_future.cancelled():
raise ValueError('expected call to be cancelled')
class _Pipe(object): class _Pipe(object):
...@@ -232,6 +222,16 @@ def _ping_pong(stub): ...@@ -232,6 +222,16 @@ def _ping_pong(stub):
'response body of invalid size %d!' % len(response.payload.body)) 'response body of invalid size %d!' % len(response.payload.body))
def _cancel_after_begin(stub):
with _Pipe() as pipe:
response_future = stub.StreamingInputCall.future(pipe)
response_future.cancel()
if not response_future.cancelled():
raise ValueError('expected cancelled method to return True')
if response_future.code() is not grpc.StatusCode.CANCELLED:
raise ValueError('expected status code CANCELLED')
def _cancel_after_first_response(stub): def _cancel_after_first_response(stub):
request_response_sizes = (31415, 9, 2653, 58979,) request_response_sizes = (31415, 9, 2653, 58979,)
request_payload_sizes = (27182, 8, 1828, 45904,) request_payload_sizes = (27182, 8, 1828, 45904,)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment