fix: distinguish Gemini timeout

This commit is contained in:
2026-10-06 15:55:01 +09:00
parent 5b0c2434bd
commit 7e6aebeb76
2 changed files with 31 additions and 0 deletions
@@ -1,5 +1,6 @@
import asyncio
import httpx
import pytest
from fastapi import HTTPException
@@ -65,6 +66,30 @@ def test_busy_gemini_is_retried_and_reported(monkeypatch):
assert "요청이 몰려" in error.value.detail
def test_gemini_timeout_is_reported(monkeypatch):
monkeypatch.setenv("GEMINI_API_KEY", "test-key")
monkeypatch.setattr(chat, "search", lambda _question: [])
class Client:
def __init__(self, timeout):
pass
async def __aenter__(self):
return self
async def __aexit__(self, *_args):
pass
async def post(self, *_args, **_kwargs):
raise httpx.ReadTimeout("timed out")
monkeypatch.setattr(chat.httpx, "AsyncClient", Client)
with pytest.raises(HTTPException) as error:
asyncio.run(chat.ask_knowledge_chat(chat.ChatRequest(question="일위대가가 뭐야"), {}))
assert error.value.status_code == 504
assert "시간 초과" in error.value.detail
def test_chat_searches_all_knowledge_markdown_except_excluded_folders(monkeypatch, tmp_path):
public = tmp_path / "original" / "법률"
guide = tmp_path / "technical_info"