From 270e1a56b51148651ed499780ba9dec5af68b33e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 17:03:30 +0000 Subject: [PATCH] fix(tests): pass mock db to whoami_handler in test_api_auth_enabled.py Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_api_auth_enabled.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_api_auth_enabled.py b/tests/test_api_auth_enabled.py index 5313cf5d..1f975685 100644 --- a/tests/test_api_auth_enabled.py +++ b/tests/test_api_auth_enabled.py @@ -116,9 +116,13 @@ class TestProtectedAPIEndpoints: } } + # Mock DB: no UserProfile found (no custom avatar) + mock_db = MagicMock() + mock_db.query.return_value.filter.return_value.first.return_value = None + import asyncio - result = asyncio.run(whoami_handler(mock_request)) + result = asyncio.run(whoami_handler(mock_request, mock_db)) assert result["id"] == "test123" assert result["email"] == "test@example.com" @@ -135,9 +139,10 @@ class TestProtectedAPIEndpoints: mock_request = MagicMock() mock_request.session = {} + mock_db = MagicMock() with pytest.raises(HTTPException) as exc_info: - asyncio.run(whoami_handler(mock_request)) + asyncio.run(whoami_handler(mock_request, mock_db)) assert exc_info.value.status_code == 401 assert "Not logged in" in exc_info.value.detail