2121
2222
2323class DaprClientTimeoutInterceptorTests (unittest .TestCase ):
24- def test_intercept_unary_unary_with_timeout (self ):
24+ @patch .object (settings , 'DAPR_API_TIMEOUT_SECONDS' , 7 )
25+ def test_intercept_unary_unary_global_timeout_with_per_call_timeout (self ):
2526 continuation = Mock ()
2627 request = Mock ()
2728 client_call_details = Mock ()
@@ -36,6 +37,8 @@ def test_intercept_unary_unary_with_timeout(self):
3637 continuation , client_call_details , request
3738 )
3839 continuation .assert_called_once_with (client_call_details , request )
40+ called_client_call_details = continuation .call_args [0 ][0 ]
41+ self .assertEqual (10 , called_client_call_details .timeout )
3942
4043 @patch .object (settings , 'DAPR_API_TIMEOUT_SECONDS' , 7 )
4144 def test_intercept_unary_unary_without_timeout (self ):
@@ -54,3 +57,37 @@ def test_intercept_unary_unary_without_timeout(self):
5457 )
5558 called_client_call_details = continuation .call_args [0 ][0 ]
5659 self .assertEqual (7 , called_client_call_details .timeout )
60+
61+ @patch .object (settings , 'DAPR_API_TIMEOUT_SECONDS' , None )
62+ def test_intercept_unary_unary_no_global_timeout_with_per_call_timeout (self ):
63+ continuation = Mock ()
64+ request = Mock ()
65+ client_call_details = Mock ()
66+ client_call_details .method = 'method'
67+ client_call_details .timeout = 10
68+ client_call_details .metadata = 'metadata'
69+ client_call_details .credentials = 'credentials'
70+ client_call_details .wait_for_ready = 'wait_for_ready'
71+ client_call_details .compression = 'compression'
72+
73+ DaprClientTimeoutInterceptor ().intercept_unary_unary (
74+ continuation , client_call_details , request
75+ )
76+ continuation .assert_called_once_with (client_call_details , request )
77+
78+ @patch .object (settings , 'DAPR_API_TIMEOUT_SECONDS' , None )
79+ def test_intercept_unary_unary_no_global_timeout_no_per_call_timeout (self ):
80+ continuation = Mock ()
81+ request = Mock ()
82+ client_call_details = Mock ()
83+ client_call_details .method = 'method'
84+ client_call_details .timeout = None
85+ client_call_details .metadata = 'metadata'
86+ client_call_details .credentials = 'credentials'
87+ client_call_details .wait_for_ready = 'wait_for_ready'
88+ client_call_details .compression = 'compression'
89+
90+ DaprClientTimeoutInterceptor ().intercept_unary_unary (
91+ continuation , client_call_details , request
92+ )
93+ continuation .assert_called_once_with (client_call_details , request )
0 commit comments