Skip to content

Commit 3d3793b

Browse files
test: enhance tracer configuration tests to include max retries validation
Added tests to verify the correct configuration and usage of the `max_retries` parameter in the tracer. Updated existing tests to incorporate `max_retries` in the configuration and assertions, ensuring that the tracer behaves as expected with this new parameter.
1 parent e279780 commit 3d3793b

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

tests/test_tracer_configuration.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def teardown_method(self):
1616
tracer._configured_pipeline_id = None
1717
tracer._configured_base_url = None
1818
tracer._configured_timeout = None
19+
tracer._configured_max_retries = None
1920
tracer._client = None
2021

2122
def test_configure_sets_global_variables(self):
@@ -24,13 +25,15 @@ def test_configure_sets_global_variables(self):
2425
pipeline_id = "test_pipeline_id"
2526
base_url = "https://test.api.com"
2627
timeout = 30.5
28+
max_retries = 5
2729

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)
2931

3032
assert tracer._configured_api_key == api_key
3133
assert tracer._configured_pipeline_id == pipeline_id
3234
assert tracer._configured_base_url == base_url
3335
assert tracer._configured_timeout == timeout
36+
assert tracer._configured_max_retries == max_retries
3437

3538
def test_configure_resets_client(self):
3639
"""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:
9194

9295
mock_openlayer.assert_called_once_with(timeout=timeout)
9396

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+
94108
@patch("openlayer.lib.tracing.tracer.Openlayer")
95109
def test_get_client_uses_all_configured_values(self, mock_openlayer: Any) -> None:
96110
"""Test that _get_client() uses all configured values together."""
97111
with patch.object(tracer, "_publish", True):
98112
api_key = "configured_api_key"
99113
base_url = "https://configured.api.com"
100114
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)
102117

103118
tracer._get_client()
104119

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)
106121

107122
@patch("openlayer.lib.tracing.tracer.DefaultHttpxClient")
108123
@patch("openlayer.lib.tracing.tracer.Openlayer")
@@ -180,14 +195,16 @@ def test_configure_with_none_values(self):
180195
api_key="initial_key",
181196
inference_pipeline_id="initial_pipeline",
182197
base_url="https://initial.com",
183-
timeout=60.0
198+
timeout=60.0,
199+
max_retries=5
184200
)
185201

186202
# 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)
188204

189205
# Values should be set to None (this is the expected behavior)
190206
assert tracer._configured_api_key is None
191207
assert tracer._configured_pipeline_id is None
192208
assert tracer._configured_base_url is None
193209
assert tracer._configured_timeout is None
210+
assert tracer._configured_max_retries is None

0 commit comments

Comments
 (0)