Make sanity tests happy

pull/21681/head
Lidi Zheng 5 years ago
parent 780bff32eb
commit 0fc1d212aa
  1. 6
      src/python/grpcio/grpc/experimental/aio/_base_call.py
  2. 1
      src/python/grpcio_tests/tests_aio/tests.json
  3. 15
      src/python/grpcio_tests/tests_aio/unit/call_test.py

@ -19,12 +19,12 @@ RPC, e.g. cancellation.
"""
from abc import ABCMeta, abstractmethod
from typing import (Any, AsyncIterable, Awaitable, Callable, Generic, Optional,
Text, Union)
from typing import AsyncIterable, Awaitable, Generic, Optional, Text, Union
import grpc
from ._typing import EOFType, MetadataType, RequestType, ResponseType, DoneCallbackType
from ._typing import (DoneCallbackType, EOFType, MetadataType, RequestType,
ResponseType)
__all__ = 'RpcContext', 'Call', 'UnaryUnaryCall', 'UnaryStreamCall'

@ -9,6 +9,7 @@
"unit.channel_argument_test.TestChannelArgument",
"unit.channel_test.TestChannel",
"unit.connectivity_test.TestConnectivityState",
"unit.done_callback_test.TestDoneCallback",
"unit.init_test.TestInsecureChannel",
"unit.init_test.TestSecureChannel",
"unit.interceptor_test.TestInterceptedUnaryUnaryCall",

@ -380,9 +380,7 @@ class TestUnaryStreamCall(_MulticallableTestMixin, AioTestBase):
request = messages_pb2.StreamingOutputCallRequest()
# First message comes back immediately
request.response_parameters.append(
messages_pb2.ResponseParameters(
size=_RESPONSE_PAYLOAD_SIZE,
))
messages_pb2.ResponseParameters(size=_RESPONSE_PAYLOAD_SIZE,))
# Second message comes back after a unit of wait time
request.response_parameters.append(
messages_pb2.ResponseParameters(
@ -391,26 +389,27 @@ class TestUnaryStreamCall(_MulticallableTestMixin, AioTestBase):
))
call = self._stub.StreamingOutputCall(
request, timeout=test_constants.SHORT_TIMEOUT*2)
request, timeout=test_constants.SHORT_TIMEOUT * 2)
response = await call.read()
self.assertEqual(_RESPONSE_PAYLOAD_SIZE, len(response.payload.body))
# Should be around the same as the timeout
remained_time = call.time_remaining()
self.assertGreater(remained_time, test_constants.SHORT_TIMEOUT*3//2)
self.assertLess(remained_time, test_constants.SHORT_TIMEOUT*2)
self.assertGreater(remained_time, test_constants.SHORT_TIMEOUT * 3 // 2)
self.assertLess(remained_time, test_constants.SHORT_TIMEOUT * 2)
response = await call.read()
self.assertEqual(_RESPONSE_PAYLOAD_SIZE, len(response.payload.body))
# Should be around the timeout minus a unit of wait time
remained_time = call.time_remaining()
self.assertGreater(remained_time, test_constants.SHORT_TIMEOUT//2)
self.assertLess(remained_time, test_constants.SHORT_TIMEOUT*3//2)
self.assertGreater(remained_time, test_constants.SHORT_TIMEOUT // 2)
self.assertLess(remained_time, test_constants.SHORT_TIMEOUT * 3 // 2)
self.assertEqual(grpc.StatusCode.OK, await call.code())
class TestStreamUnaryCall(_MulticallableTestMixin, AioTestBase):
async def test_cancel_stream_unary(self):

Loading…
Cancel
Save