|
|
@ -13,18 +13,20 @@ |
|
|
|
# limitations under the License. |
|
|
|
# limitations under the License. |
|
|
|
"""The Python implementation of the GRPC helloworld.Greeter client.""" |
|
|
|
"""The Python implementation of the GRPC helloworld.Greeter client.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from concurrent import futures |
|
|
|
import contextlib |
|
|
|
import contextlib |
|
|
|
import datetime |
|
|
|
import datetime |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
import unittest |
|
|
|
import unittest |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO(https://github.com/grpc/grpc/issues/29284) |
|
|
|
|
|
|
|
# isort: off |
|
|
|
import grpc |
|
|
|
import grpc |
|
|
|
|
|
|
|
|
|
|
|
from google.protobuf import duration_pb2 |
|
|
|
from google.protobuf import duration_pb2 |
|
|
|
from google.protobuf import timestamp_pb2 |
|
|
|
from google.protobuf import timestamp_pb2 |
|
|
|
from concurrent import futures |
|
|
|
|
|
|
|
from google.cloud import helloworld_pb2 |
|
|
|
from google.cloud import helloworld_pb2 |
|
|
|
from google.cloud import helloworld_pb2_grpc |
|
|
|
from google.cloud import helloworld_pb2_grpc |
|
|
|
|
|
|
|
# isort: on |
|
|
|
|
|
|
|
|
|
|
|
_HOST = 'localhost' |
|
|
|
_HOST = 'localhost' |
|
|
|
_SERVER_ADDRESS = '{}:0'.format(_HOST) |
|
|
|
_SERVER_ADDRESS = '{}:0'.format(_HOST) |
|
|
@ -56,6 +58,7 @@ def _listening_server(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImportTest(unittest.TestCase): |
|
|
|
class ImportTest(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
def test_import(self): |
|
|
|
def test_import(self): |
|
|
|
with _listening_server() as port: |
|
|
|
with _listening_server() as port: |
|
|
|
with grpc.insecure_channel('{}:{}'.format(_HOST, port)) as channel: |
|
|
|
with grpc.insecure_channel('{}:{}'.format(_HOST, port)) as channel: |
|
|
@ -66,7 +69,7 @@ class ImportTest(unittest.TestCase): |
|
|
|
name='you', |
|
|
|
name='you', |
|
|
|
request_initiation=request_timestamp, |
|
|
|
request_initiation=request_timestamp, |
|
|
|
), |
|
|
|
), |
|
|
|
wait_for_ready=True) |
|
|
|
wait_for_ready=True) |
|
|
|
self.assertEqual(response.message, "Hello, you!") |
|
|
|
self.assertEqual(response.message, "Hello, you!") |
|
|
|
self.assertGreater(response.request_duration.nanos, 0) |
|
|
|
self.assertGreater(response.request_duration.nanos, 0) |
|
|
|
|
|
|
|
|