22
33from durabletask import client
44from durabletask .internal .grpc_interceptor import DefaultClientInterceptorImpl
5- from durabletask .internal .shared import get_default_host_address , get_grpc_channel
5+ from durabletask .internal .shared import (
6+ DEFAULT_GRPC_KEEPALIVE_OPTIONS ,
7+ get_default_host_address ,
8+ get_grpc_channel ,
9+ )
10+
11+ EXPECTED_DEFAULT_OPTIONS = list (DEFAULT_GRPC_KEEPALIVE_OPTIONS )
612
713HOST_ADDRESS = "localhost:50051"
814METADATA = [("key1" , "value1" ), ("key2" , "value2" )]
@@ -14,7 +20,7 @@ def test_get_grpc_channel_insecure():
1420 get_grpc_channel (HOST_ADDRESS , False , interceptors = INTERCEPTORS )
1521 args , kwargs = mock_channel .call_args
1622 assert args [0 ] == HOST_ADDRESS
17- assert "options" in kwargs and kwargs ["options" ] is None
23+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
1824
1925
2026def test_get_grpc_channel_secure ():
@@ -26,15 +32,15 @@ def test_get_grpc_channel_secure():
2632 args , kwargs = mock_channel .call_args
2733 assert args [0 ] == HOST_ADDRESS
2834 assert args [1 ] == mock_credentials .return_value
29- assert "options" in kwargs and kwargs ["options" ] is None
35+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
3036
3137
3238def test_get_grpc_channel_default_host_address ():
3339 with patch ("grpc.insecure_channel" ) as mock_channel :
3440 get_grpc_channel (None , False , interceptors = INTERCEPTORS )
3541 args , kwargs = mock_channel .call_args
3642 assert args [0 ] == get_default_host_address ()
37- assert "options" in kwargs and kwargs ["options" ] is None
43+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
3844
3945
4046def test_get_grpc_channel_with_metadata ():
@@ -45,7 +51,7 @@ def test_get_grpc_channel_with_metadata():
4551 get_grpc_channel (HOST_ADDRESS , False , interceptors = INTERCEPTORS )
4652 args , kwargs = mock_channel .call_args
4753 assert args [0 ] == HOST_ADDRESS
48- assert "options" in kwargs and kwargs ["options" ] is None
54+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
4955 mock_intercept_channel .assert_called_once ()
5056
5157 # Capture and check the arguments passed to intercept_channel()
@@ -66,61 +72,61 @@ def test_grpc_channel_with_host_name_protocol_stripping():
6672 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
6773 args , kwargs = mock_insecure_channel .call_args
6874 assert args [0 ] == host_name
69- assert "options" in kwargs and kwargs ["options" ] is None
75+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
7076
7177 prefix = "http://"
7278 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
7379 args , kwargs = mock_insecure_channel .call_args
7480 assert args [0 ] == host_name
75- assert "options" in kwargs and kwargs ["options" ] is None
81+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
7682
7783 prefix = "HTTP://"
7884 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
7985 args , kwargs = mock_insecure_channel .call_args
8086 assert args [0 ] == host_name
81- assert "options" in kwargs and kwargs ["options" ] is None
87+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
8288
8389 prefix = "GRPC://"
8490 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
8591 args , kwargs = mock_insecure_channel .call_args
8692 assert args [0 ] == host_name
87- assert "options" in kwargs and kwargs ["options" ] is None
93+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
8894
8995 prefix = ""
9096 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
9197 args , kwargs = mock_insecure_channel .call_args
9298 assert args [0 ] == host_name
93- assert "options" in kwargs and kwargs ["options" ] is None
99+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
94100
95101 prefix = "grpcs://"
96102 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
97103 args , kwargs = mock_secure_channel .call_args
98104 assert args [0 ] == host_name
99- assert "options" in kwargs and kwargs ["options" ] is None
105+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
100106
101107 prefix = "https://"
102108 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
103109 args , kwargs = mock_secure_channel .call_args
104110 assert args [0 ] == host_name
105- assert "options" in kwargs and kwargs ["options" ] is None
111+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
106112
107113 prefix = "HTTPS://"
108114 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
109115 args , kwargs = mock_secure_channel .call_args
110116 assert args [0 ] == host_name
111- assert "options" in kwargs and kwargs ["options" ] is None
117+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
112118
113119 prefix = "GRPCS://"
114120 get_grpc_channel (prefix + host_name , interceptors = INTERCEPTORS )
115121 args , kwargs = mock_secure_channel .call_args
116122 assert args [0 ] == host_name
117- assert "options" in kwargs and kwargs ["options" ] is None
123+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
118124
119125 prefix = ""
120126 get_grpc_channel (prefix + host_name , True , interceptors = INTERCEPTORS )
121127 args , kwargs = mock_secure_channel .call_args
122128 assert args [0 ] == host_name
123- assert "options" in kwargs and kwargs ["options" ] is None
129+ assert "options" in kwargs and kwargs ["options" ] == EXPECTED_DEFAULT_OPTIONS
124130
125131
126132def test_sync_channel_passes_base_options_and_max_lengths ():
0 commit comments