1 # Copyright 2016 gRPC authors.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Test of gRPC Python's application-layer API."""
23 from tests.unit import _from_grpc_import_star
26 class AllTest(unittest.TestCase):
29 expected_grpc_code_elements = (
31 'FutureCancelledError',
33 'ChannelConnectivity',
42 'AuthMetadataContext',
43 'AuthMetadataPluginCallback',
45 'ServerCertificateConfiguration',
47 'UnaryUnaryMultiCallable',
48 'UnaryStreamMultiCallable',
49 'StreamUnaryMultiCallable',
50 'StreamStreamMultiCallable',
51 'UnaryUnaryClientInterceptor',
52 'UnaryStreamClientInterceptor',
53 'StreamUnaryClientInterceptor',
54 'StreamStreamClientInterceptor',
63 'LocalConnectionType',
64 'local_channel_credentials',
65 'local_server_credentials',
66 'alts_channel_credentials',
67 'alts_server_credentials',
68 'unary_unary_rpc_method_handler',
69 'unary_stream_rpc_method_handler',
70 'stream_unary_rpc_method_handler',
72 'stream_stream_rpc_method_handler',
73 'method_handlers_generic_handler',
74 'ssl_channel_credentials',
75 'metadata_call_credentials',
76 'access_token_call_credentials',
77 'composite_call_credentials',
78 'composite_channel_credentials',
79 'ssl_server_credentials',
80 'ssl_server_certificate_configuration',
81 'dynamic_ssl_server_credentials',
82 'channel_ready_future',
89 six.assertCountEqual(self, expected_grpc_code_elements,
90 _from_grpc_import_star.GRPC_ELEMENTS)
93 class ChannelConnectivityTest(unittest.TestCase):
95 def testChannelConnectivity(self):
96 self.assertSequenceEqual((
97 grpc.ChannelConnectivity.IDLE,
98 grpc.ChannelConnectivity.CONNECTING,
99 grpc.ChannelConnectivity.READY,
100 grpc.ChannelConnectivity.TRANSIENT_FAILURE,
101 grpc.ChannelConnectivity.SHUTDOWN,
102 ), tuple(grpc.ChannelConnectivity))
105 class ChannelTest(unittest.TestCase):
107 def test_secure_channel(self):
108 channel_credentials = grpc.ssl_channel_credentials()
109 channel = grpc.secure_channel('google.com:443', channel_credentials)
113 if __name__ == '__main__':
114 logging.basicConfig()
115 unittest.main(verbosity=2)