""" Tests for API error handling - ensuring JSON responses for API routes. """ import pytest from fastapi.testclient import TestClient from app.models import FileRecord from unittest.mock import patch @pytest.mark.integration @pytest.mark.requires_db class TestAPIErrorHandling: """Tests for API error responses - ensuring they return JSON, not HTML.""" def test_delete_nonexistent_file_returns_json_404(self, client: TestClient): """Test that deleting a non-existent file returns JSON 404, not HTML.""" response = client.delete("/api/files/99999") # Should return 404 assert response.status_code == 404 # Should be JSON, not HTML content_type = response.headers.get("content-type", "") assert "application/json" in content_type, f"Expected JSON but got {content_type}" # Should not contain HTML assert not response.text.startswith("