From 46804d8125ac040f653d96f79951f479dfb158fd Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Thu, 30 Jan 2020 00:00:18 +0100 Subject: [PATCH] Add test for stream unary close channel, remove irrelevant code --- .../tests_aio/unit/close_channel_test.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py b/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py index f3b89e4e2d5..61bc18180bb 100644 --- a/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py +++ b/src/python/grpcio_tests/tests_aio/unit/close_channel_test.py @@ -81,7 +81,6 @@ class TestCloseChannel(AioTestBase): ) call = UnaryCallWithSleep(messages_pb2.SimpleRequest()) - task = asyncio.ensure_future(call) await channel.close(grace=UNARY_CALL_WITH_SLEEP_VALUE * 2) @@ -96,7 +95,6 @@ class TestCloseChannel(AioTestBase): ) call = UnaryCallWithSleep(messages_pb2.SimpleRequest()) - task = asyncio.ensure_future(call) await channel.close(None) @@ -133,6 +131,19 @@ class TestCloseChannel(AioTestBase): self.assertEqual(channel._ongoing_calls.size(), 0) + async def test_close_stream_unary(self): + channel = aio.insecure_channel(self._server_target) + stub = test_pb2_grpc.TestServiceStub(channel) + + calls = [stub.StreamingInputCall() for _ in range(2)] + + await channel.close() + + for call in calls: + self.assertTrue(call.cancelled()) + + self.assertEqual(channel._ongoing_calls.size(), 0) + async def test_close_stream_stream(self): channel = aio.insecure_channel(self._server_target) stub = test_pb2_grpc.TestServiceStub(channel)