@@ -183,79 +183,6 @@ def test_throws_badrequest_excpetion(
183183 == "Audit Log could not be processed due to missing or incorrect data."
184184 )
185185
186- def test_handles_missing_success_field (
187- self , mock_audit_log_event , mock_http_client_with_response
188- ):
189- """Test that schema validation fails when response is missing required fields."""
190- organization_id = "org_123456789"
191-
192- # Mock response missing the 'success' field
193- mock_http_client_with_response (
194- self .http_client ,
195- {}, # Empty response
196- 200 ,
197- )
198-
199- with pytest .raises (
200- Exception
201- ) as excinfo : # Pydantic will raise ValidationError
202- self .audit_logs .create_event (
203- organization_id = organization_id ,
204- event = mock_audit_log_event ,
205- )
206-
207- # Assert that validation error occurred
208- assert (
209- "success" in str (excinfo .value ).lower ()
210- or "validation" in str (excinfo .value ).lower ()
211- )
212-
213- def test_handles_invalid_success_type (
214- self , mock_audit_log_event , mock_http_client_with_response
215- ):
216- """Test that schema validation fails when response has incorrect field types."""
217- organization_id = "org_123456789"
218-
219- # Mock response with wrong type for 'success' field (non-coercible value)
220- mock_http_client_with_response (
221- self .http_client ,
222- {"success" : ["invalid" , "list" ]}, # List instead of boolean
223- 200 ,
224- )
225-
226- with pytest .raises (
227- Exception
228- ) as excinfo : # Pydantic will raise ValidationError
229- self .audit_logs .create_event (
230- organization_id = organization_id ,
231- event = mock_audit_log_event ,
232- )
233-
234- # Assert that validation error occurred
235- assert excinfo .value is not None
236-
237- def test_handles_malformed_json_response (
238- self , mock_audit_log_event , mock_http_client_with_response
239- ):
240- """Test that schema validation fails when response is completely malformed."""
241- organization_id = "org_123456789"
242-
243- # Mock response with unexpected structure
244- mock_http_client_with_response (
245- self .http_client ,
246- {"unexpected" : "data" , "structure" : 123 },
247- 200 ,
248- )
249-
250- with pytest .raises (Exception ) as excinfo :
251- self .audit_logs .create_event (
252- organization_id = organization_id ,
253- event = mock_audit_log_event ,
254- )
255-
256- # Assert that validation error occurred
257- assert excinfo .value is not None
258-
259186 class TestCreateExport (_TestSetup ):
260187 def test_succeeds (self , mock_http_client_with_response ):
261188 organization_id = "org_123456789"
0 commit comments