fix(tests): pass mock db to whoami_handler in test_api_auth_enabled.py

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-12 17:03:30 +00:00
parent 9583d6d96f
commit 270e1a56b5
+7 -2
View File
@@ -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