66
77HOST_ADDRESS = 'localhost:50051'
88METADATA = [('key1' , 'value1' ), ('key2' , 'value2' )]
9-
9+ INTERCEPTORS = DefaultClientInterceptorImpl ( METADATA )
1010
1111def test_get_grpc_channel_insecure ():
1212 with patch ('grpc.insecure_channel' ) as mock_channel :
13- get_grpc_channel (HOST_ADDRESS , METADATA , False )
13+ get_grpc_channel (HOST_ADDRESS , False , interceptors = INTERCEPTORS )
1414 mock_channel .assert_called_once_with (HOST_ADDRESS )
1515
1616
1717def test_get_grpc_channel_secure ():
1818 with patch ('grpc.secure_channel' ) as mock_channel , patch (
1919 'grpc.ssl_channel_credentials' ) as mock_credentials :
20- get_grpc_channel (HOST_ADDRESS , METADATA , True )
20+ get_grpc_channel (HOST_ADDRESS , True , interceptors = INTERCEPTORS )
2121 mock_channel .assert_called_once_with (HOST_ADDRESS , mock_credentials .return_value )
2222
2323
2424def test_get_grpc_channel_default_host_address ():
2525 with patch ('grpc.insecure_channel' ) as mock_channel :
26- get_grpc_channel (None , METADATA , False )
26+ get_grpc_channel (None , False , interceptors = INTERCEPTORS )
2727 mock_channel .assert_called_once_with (get_default_host_address ())
2828
2929
3030def test_get_grpc_channel_with_metadata ():
3131 with patch ('grpc.insecure_channel' ) as mock_channel , patch (
3232 'grpc.intercept_channel' ) as mock_intercept_channel :
33- get_grpc_channel (HOST_ADDRESS , METADATA , False )
33+ get_grpc_channel (HOST_ADDRESS , False , interceptors = INTERCEPTORS )
3434 mock_channel .assert_called_once_with (HOST_ADDRESS )
3535 mock_intercept_channel .assert_called_once ()
3636
@@ -48,41 +48,41 @@ def test_grpc_channel_with_host_name_protocol_stripping():
4848 host_name = "myserver.com:1234"
4949
5050 prefix = "grpc://"
51- get_grpc_channel (prefix + host_name , METADATA )
51+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
5252 mock_insecure_channel .assert_called_with (host_name )
5353
5454 prefix = "http://"
55- get_grpc_channel (prefix + host_name , METADATA )
55+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
5656 mock_insecure_channel .assert_called_with (host_name )
5757
5858 prefix = "HTTP://"
59- get_grpc_channel (prefix + host_name , METADATA )
59+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
6060 mock_insecure_channel .assert_called_with (host_name )
6161
6262 prefix = "GRPC://"
63- get_grpc_channel (prefix + host_name , METADATA )
63+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
6464 mock_insecure_channel .assert_called_with (host_name )
6565
6666 prefix = ""
67- get_grpc_channel (prefix + host_name , METADATA )
67+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
6868 mock_insecure_channel .assert_called_with (host_name )
6969
7070 prefix = "grpcs://"
71- get_grpc_channel (prefix + host_name , METADATA )
71+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
7272 mock_secure_channel .assert_called_with (host_name , ANY )
7373
7474 prefix = "https://"
75- get_grpc_channel (prefix + host_name , METADATA )
75+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
7676 mock_secure_channel .assert_called_with (host_name , ANY )
7777
7878 prefix = "HTTPS://"
79- get_grpc_channel (prefix + host_name , METADATA )
79+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
8080 mock_secure_channel .assert_called_with (host_name , ANY )
8181
8282 prefix = "GRPCS://"
83- get_grpc_channel (prefix + host_name , METADATA )
83+ get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
8484 mock_secure_channel .assert_called_with (host_name , ANY )
8585
8686 prefix = ""
87- get_grpc_channel (prefix + host_name , METADATA , True )
87+ get_grpc_channel (prefix + host_name , True , interceptors = INTERCEPTORS )
8888 mock_secure_channel .assert_called_with (host_name , ANY )
0 commit comments