fixed a bug

This commit is contained in:
2026-09-06 08:32:04 +08:00
parent 0baff0b447
commit aca36c78c1
8 changed files with 46 additions and 14 deletions

View File

@@ -47,6 +47,21 @@ def test_ai_tutor_parses_chat_completion(monkeypatch):
assert timeout == 1.5
def test_ai_tutor_resolves_openai_compatible_base_url(monkeypatch):
endpoints = []
def fake_post(endpoint, **kwargs):
endpoints.append(endpoint)
return FakeResponse(body={"choices": [{"message": {"content": "ok"}}]})
monkeypatch.setattr("sentence_api.ai_tutor.requests.post", fake_post)
tutor = AITutor("https://ai.test:8080/v1", "secret", "test-model", 1)
assert tutor.explain("Hello.") == "ok"
assert endpoints == ["https://ai.test:8080/v1/chat/completions"]
assert tutor.request_url == "https://ai.test:8080/v1/chat/completions"
def test_ai_tutor_rejects_unexpected_response(monkeypatch):
monkeypatch.setattr(
"sentence_api.ai_tutor.requests.post",