@@ -62,13 +62,8 @@ def mock_client(self):
6262 """Create a mock OpenAI client."""
6363 return MagicMock ()
6464
65- @pytest .fixture
66- def mock_logger (self ):
67- """Create a mock logger."""
68- return MagicMock ()
69-
7065 @pytest .mark .asyncio
71- async def test_invokes_openai_chat_completions_and_returns_response (self , mock_client , mock_logger ):
66+ async def test_invokes_openai_chat_completions_and_returns_response (self , mock_client ):
7267 """Should invoke OpenAI chat completions and return response."""
7368 mock_response = MagicMock ()
7469 mock_response .choices = [MagicMock ()]
@@ -83,7 +78,7 @@ async def test_invokes_openai_chat_completions_and_returns_response(self, mock_c
8378 mock_client .chat .completions = MagicMock ()
8479 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
8580
86- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
81+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
8782 messages = [LDMessage (role = 'user' , content = 'Hello!' )]
8883 result = await provider .invoke_model (messages )
8984
@@ -101,7 +96,7 @@ async def test_invokes_openai_chat_completions_and_returns_response(self, mock_c
10196 assert result .metrics .usage .output == 15
10297
10398 @pytest .mark .asyncio
104- async def test_returns_unsuccessful_response_when_no_content (self , mock_client , mock_logger ):
99+ async def test_returns_unsuccessful_response_when_no_content (self , mock_client ):
105100 """Should return unsuccessful response when no content in response."""
106101 mock_response = MagicMock ()
107102 mock_response .choices = [MagicMock ()]
@@ -113,7 +108,7 @@ async def test_returns_unsuccessful_response_when_no_content(self, mock_client,
113108 mock_client .chat .completions = MagicMock ()
114109 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
115110
116- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
111+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
117112 messages = [LDMessage (role = 'user' , content = 'Hello!' )]
118113 result = await provider .invoke_model (messages )
119114
@@ -122,7 +117,7 @@ async def test_returns_unsuccessful_response_when_no_content(self, mock_client,
122117 assert result .metrics .success is False
123118
124119 @pytest .mark .asyncio
125- async def test_returns_unsuccessful_response_when_choices_empty (self , mock_client , mock_logger ):
120+ async def test_returns_unsuccessful_response_when_choices_empty (self , mock_client ):
126121 """Should return unsuccessful response when choices array is empty."""
127122 mock_response = MagicMock ()
128123 mock_response .choices = []
@@ -132,7 +127,7 @@ async def test_returns_unsuccessful_response_when_choices_empty(self, mock_clien
132127 mock_client .chat .completions = MagicMock ()
133128 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
134129
135- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
130+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
136131 messages = [LDMessage (role = 'user' , content = 'Hello!' )]
137132 result = await provider .invoke_model (messages )
138133
@@ -141,20 +136,19 @@ async def test_returns_unsuccessful_response_when_choices_empty(self, mock_clien
141136 assert result .metrics .success is False
142137
143138 @pytest .mark .asyncio
144- async def test_returns_unsuccessful_response_when_exception_thrown (self , mock_client , mock_logger ):
139+ async def test_returns_unsuccessful_response_when_exception_thrown (self , mock_client ):
145140 """Should return unsuccessful response when exception is thrown."""
146141 mock_client .chat = MagicMock ()
147142 mock_client .chat .completions = MagicMock ()
148143 mock_client .chat .completions .create = AsyncMock (side_effect = Exception ('API Error' ))
149144
150- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
145+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
151146 messages = [LDMessage (role = 'user' , content = 'Hello!' )]
152147 result = await provider .invoke_model (messages )
153148
154149 assert result .message .role == 'assistant'
155150 assert result .message .content == ''
156151 assert result .metrics .success is False
157- mock_logger .warn .assert_called ()
158152
159153
160154class TestInvokeStructuredModel :
@@ -165,13 +159,8 @@ def mock_client(self):
165159 """Create a mock OpenAI client."""
166160 return MagicMock ()
167161
168- @pytest .fixture
169- def mock_logger (self ):
170- """Create a mock logger."""
171- return MagicMock ()
172-
173162 @pytest .mark .asyncio
174- async def test_invokes_openai_with_structured_output (self , mock_client , mock_logger ):
163+ async def test_invokes_openai_with_structured_output (self , mock_client ):
175164 """Should invoke OpenAI with structured output and return parsed response."""
176165 mock_response = MagicMock ()
177166 mock_response .choices = [MagicMock ()]
@@ -186,7 +175,7 @@ async def test_invokes_openai_with_structured_output(self, mock_client, mock_log
186175 mock_client .chat .completions = MagicMock ()
187176 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
188177
189- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
178+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
190179 messages = [LDMessage (role = 'user' , content = 'Tell me about a person' )]
191180 response_structure = {
192181 'type' : 'object' ,
@@ -209,7 +198,7 @@ async def test_invokes_openai_with_structured_output(self, mock_client, mock_log
209198 assert result .metrics .usage .output == 10
210199
211200 @pytest .mark .asyncio
212- async def test_returns_unsuccessful_when_no_content_in_structured_response (self , mock_client , mock_logger ):
201+ async def test_returns_unsuccessful_when_no_content_in_structured_response (self , mock_client ):
213202 """Should return unsuccessful response when no content in structured response."""
214203 mock_response = MagicMock ()
215204 mock_response .choices = [MagicMock ()]
@@ -221,7 +210,7 @@ async def test_returns_unsuccessful_when_no_content_in_structured_response(self,
221210 mock_client .chat .completions = MagicMock ()
222211 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
223212
224- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
213+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
225214 messages = [LDMessage (role = 'user' , content = 'Tell me about a person' )]
226215 response_structure = {'type' : 'object' }
227216
@@ -232,7 +221,7 @@ async def test_returns_unsuccessful_when_no_content_in_structured_response(self,
232221 assert result .metrics .success is False
233222
234223 @pytest .mark .asyncio
235- async def test_handles_json_parsing_errors (self , mock_client , mock_logger ):
224+ async def test_handles_json_parsing_errors (self , mock_client ):
236225 """Should handle JSON parsing errors gracefully."""
237226 mock_response = MagicMock ()
238227 mock_response .choices = [MagicMock ()]
@@ -247,7 +236,7 @@ async def test_handles_json_parsing_errors(self, mock_client, mock_logger):
247236 mock_client .chat .completions = MagicMock ()
248237 mock_client .chat .completions .create = AsyncMock (return_value = mock_response )
249238
250- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
239+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
251240 messages = [LDMessage (role = 'user' , content = 'Tell me about a person' )]
252241 response_structure = {'type' : 'object' }
253242
@@ -258,16 +247,15 @@ async def test_handles_json_parsing_errors(self, mock_client, mock_logger):
258247 assert result .metrics .success is False
259248 assert result .metrics .usage is not None
260249 assert result .metrics .usage .total == 15
261- mock_logger .warn .assert_called ()
262250
263251 @pytest .mark .asyncio
264- async def test_returns_unsuccessful_response_when_exception_thrown (self , mock_client , mock_logger ):
252+ async def test_returns_unsuccessful_response_when_exception_thrown (self , mock_client ):
265253 """Should return unsuccessful response when exception is thrown."""
266254 mock_client .chat = MagicMock ()
267255 mock_client .chat .completions = MagicMock ()
268256 mock_client .chat .completions .create = AsyncMock (side_effect = Exception ('API Error' ))
269257
270- provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {}, mock_logger )
258+ provider = OpenAIProvider (mock_client , 'gpt-3.5-turbo' , {})
271259 messages = [LDMessage (role = 'user' , content = 'Tell me about a person' )]
272260 response_structure = {'type' : 'object' }
273261
@@ -276,7 +264,6 @@ async def test_returns_unsuccessful_response_when_exception_thrown(self, mock_cl
276264 assert result .data == {}
277265 assert result .raw_response == ''
278266 assert result .metrics .success is False
279- mock_logger .warn .assert_called ()
280267
281268
282269class TestGetClient :
@@ -334,21 +321,3 @@ async def test_handles_missing_model_config(self):
334321 assert result ._model_name == ''
335322 assert result ._parameters == {}
336323
337-
338- class TestCreateAIMetrics :
339- """Tests for deprecated create_ai_metrics static method."""
340-
341- def test_delegates_to_get_ai_metrics_from_response (self ):
342- """Should delegate to get_ai_metrics_from_response."""
343- mock_response = MagicMock ()
344- mock_response .usage = MagicMock ()
345- mock_response .usage .prompt_tokens = 50
346- mock_response .usage .completion_tokens = 50
347- mock_response .usage .total_tokens = 100
348-
349- result = OpenAIProvider .create_ai_metrics (mock_response )
350-
351- assert result .success is True
352- assert result .usage is not None
353- assert result .usage .total == 100
354-
0 commit comments