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',
41 'AuthMetadataContext',
42 'AuthMetadataPluginCallback',
44 'ServerCertificateConfiguration',
46 'UnaryUnaryMultiCallable',
47 'UnaryStreamMultiCallable',
48 'StreamUnaryMultiCallable',
49 'StreamStreamMultiCallable',
50 'UnaryUnaryClientInterceptor',
51 'UnaryStreamClientInterceptor',
52 'StreamUnaryClientInterceptor',
53 'StreamStreamClientInterceptor',
62 'unary_unary_rpc_method_handler',
63 'unary_stream_rpc_method_handler',
64 'stream_unary_rpc_method_handler',
66 'stream_stream_rpc_method_handler',
67 'method_handlers_generic_handler',
68 'ssl_channel_credentials',
69 'metadata_call_credentials',
70 'access_token_call_credentials',
71 'composite_call_credentials',
72 'composite_channel_credentials',
73 'ssl_server_credentials',
74 'ssl_server_certificate_configuration',
75 'dynamic_ssl_server_credentials',
76 'channel_ready_future',
83 six.assertCountEqual(self, expected_grpc_code_elements,
84 _from_grpc_import_star.GRPC_ELEMENTS)
87 class ChannelConnectivityTest(unittest.TestCase):
89 def testChannelConnectivity(self):
90 self.assertSequenceEqual((
91 grpc.ChannelConnectivity.IDLE,
92 grpc.ChannelConnectivity.CONNECTING,
93 grpc.ChannelConnectivity.READY,
94 grpc.ChannelConnectivity.TRANSIENT_FAILURE,
95 grpc.ChannelConnectivity.SHUTDOWN,
96 ), tuple(grpc.ChannelConnectivity))
99 class ChannelTest(unittest.TestCase):
101 def test_secure_channel(self):
102 channel_credentials = grpc.ssl_channel_credentials()
103 channel = grpc.secure_channel('google.com:443', channel_credentials)
107 if __name__ == '__main__':
108 logging.basicConfig()
109 unittest.main(verbosity=2)