Skip to content

Commit

Permalink
Fix the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lidizheng committed Jan 16, 2020
1 parent 21670ed commit 780bff3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/python/grpcio_tests/tests_aio/unit/call_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ async def test_time_remaining(self):
request.response_parameters.append(
messages_pb2.ResponseParameters(
size=_RESPONSE_PAYLOAD_SIZE,
interval_us=_INFINITE_INTERVAL_US,
))
# Second message comes back after a unit of wait time
request.response_parameters.append(
Expand All @@ -397,13 +396,19 @@ async def test_time_remaining(self):
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//2)
self.assertLess(remained_time, test_constants.SHORT_TIMEOUT*3//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.assertEqual(grpc.StatusCode.OK, await call.code())

class TestStreamUnaryCall(_MulticallableTestMixin, AioTestBase):
Expand Down

0 comments on commit 780bff3

Please sign in to comment.