@@ -16,6 +16,7 @@ def teardown_method(self):
16
16
tracer ._configured_pipeline_id = None
17
17
tracer ._configured_base_url = None
18
18
tracer ._configured_timeout = None
19
+ tracer ._configured_max_retries = None
19
20
tracer ._client = None
20
21
21
22
def test_configure_sets_global_variables (self ):
@@ -24,13 +25,15 @@ def test_configure_sets_global_variables(self):
24
25
pipeline_id = "test_pipeline_id"
25
26
base_url = "https://test.api.com"
26
27
timeout = 30.5
28
+ max_retries = 5
27
29
28
- tracer .configure (api_key = api_key , inference_pipeline_id = pipeline_id , base_url = base_url , timeout = timeout )
30
+ tracer .configure (api_key = api_key , inference_pipeline_id = pipeline_id , base_url = base_url , timeout = timeout , max_retries = max_retries )
29
31
30
32
assert tracer ._configured_api_key == api_key
31
33
assert tracer ._configured_pipeline_id == pipeline_id
32
34
assert tracer ._configured_base_url == base_url
33
35
assert tracer ._configured_timeout == timeout
36
+ assert tracer ._configured_max_retries == max_retries
34
37
35
38
def test_configure_resets_client (self ):
36
39
"""Test that configure() resets the client to force recreation."""
@@ -91,18 +94,30 @@ def test_get_client_uses_configured_timeout(self, mock_openlayer: Any) -> None:
91
94
92
95
mock_openlayer .assert_called_once_with (timeout = timeout )
93
96
97
+ @patch ("openlayer.lib.tracing.tracer.Openlayer" )
98
+ def test_get_client_uses_configured_max_retries (self , mock_openlayer : Any ) -> None :
99
+ """Test that _get_client() uses the configured max_retries."""
100
+ with patch .object (tracer , "_publish" , True ):
101
+ max_retries = 10
102
+ tracer .configure (max_retries = max_retries )
103
+
104
+ tracer ._get_client ()
105
+
106
+ mock_openlayer .assert_called_once_with (max_retries = max_retries )
107
+
94
108
@patch ("openlayer.lib.tracing.tracer.Openlayer" )
95
109
def test_get_client_uses_all_configured_values (self , mock_openlayer : Any ) -> None :
96
110
"""Test that _get_client() uses all configured values together."""
97
111
with patch .object (tracer , "_publish" , True ):
98
112
api_key = "configured_api_key"
99
113
base_url = "https://configured.api.com"
100
114
timeout = 25
101
- tracer .configure (api_key = api_key , base_url = base_url , timeout = timeout )
115
+ max_retries = 3
116
+ tracer .configure (api_key = api_key , base_url = base_url , timeout = timeout , max_retries = max_retries )
102
117
103
118
tracer ._get_client ()
104
119
105
- mock_openlayer .assert_called_once_with (api_key = api_key , base_url = base_url , timeout = timeout )
120
+ mock_openlayer .assert_called_once_with (api_key = api_key , base_url = base_url , timeout = timeout , max_retries = max_retries )
106
121
107
122
@patch ("openlayer.lib.tracing.tracer.DefaultHttpxClient" )
108
123
@patch ("openlayer.lib.tracing.tracer.Openlayer" )
@@ -180,14 +195,16 @@ def test_configure_with_none_values(self):
180
195
api_key = "initial_key" ,
181
196
inference_pipeline_id = "initial_pipeline" ,
182
197
base_url = "https://initial.com" ,
183
- timeout = 60.0
198
+ timeout = 60.0 ,
199
+ max_retries = 5
184
200
)
185
201
186
202
# Configure with None values
187
- tracer .configure (api_key = None , inference_pipeline_id = None , base_url = None , timeout = None )
203
+ tracer .configure (api_key = None , inference_pipeline_id = None , base_url = None , timeout = None , max_retries = None )
188
204
189
205
# Values should be set to None (this is the expected behavior)
190
206
assert tracer ._configured_api_key is None
191
207
assert tracer ._configured_pipeline_id is None
192
208
assert tracer ._configured_base_url is None
193
209
assert tracer ._configured_timeout is None
210
+ assert tracer ._configured_max_retries is None
0 commit comments