refactor: establish standalone application boundary
This commit is contained in:
@@ -7,11 +7,11 @@ import urllib.error
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from assistant_agent import ReviewAssistantError, stream_review_assistant
|
||||
from backend.features.heaven.agent import HeavenAgentError, interpret_heaven
|
||||
from backend.features.mentor.agent import MentorAgentError, MentorSkill, stream_with_mentor
|
||||
from backend.features.review.agent import ReviewAssistantError, stream_review_assistant
|
||||
from backend.features.screener.compiler import LLMCompilerError, test_llm_connection
|
||||
from backend.llm import transport
|
||||
from heaven_agent import HeavenAgentError, interpret_heaven
|
||||
from llm_strategy import LLMCompilerError, test_llm_connection
|
||||
from mentor_agent import MentorAgentError, MentorSkill, stream_with_mentor
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -158,25 +158,33 @@ class FeatureErrorMappingTests(unittest.TestCase):
|
||||
path=Path("SKILL.md"),
|
||||
)
|
||||
with patch(
|
||||
"mentor_agent.llm_transport.stream_chat_completion", side_effect=error
|
||||
"backend.features.mentor.agent.llm_transport.stream_chat_completion",
|
||||
side_effect=error,
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
MentorAgentError, "问师模型调用失败(HTTP 429):capacity"
|
||||
):
|
||||
list(stream_with_mentor(skill, {}, "问题", [], "key", "https://x", "m"))
|
||||
with patch("heaven_agent.llm_transport.chat_completion", side_effect=error):
|
||||
with patch(
|
||||
"backend.features.heaven.agent.llm_transport.chat_completion",
|
||||
side_effect=error,
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
HeavenAgentError, "问天模型调用失败(HTTP 429):capacity"
|
||||
):
|
||||
interpret_heaven("heart", {}, "key", "https://x", "m")
|
||||
with patch(
|
||||
"assistant_agent.llm_transport.stream_chat_completion", side_effect=error
|
||||
"backend.features.review.agent.llm_transport.stream_chat_completion",
|
||||
side_effect=error,
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
ReviewAssistantError, "智能解读服务暂不可用(429)"
|
||||
):
|
||||
list(stream_review_assistant({}, "问题", [], "key", "https://x", "m"))
|
||||
with patch("llm_strategy.llm_transport.chat_completion", side_effect=error):
|
||||
with patch(
|
||||
"backend.features.screener.compiler.llm_transport.chat_completion",
|
||||
side_effect=error,
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
LLMCompilerError, "模型连接测试失败(HTTP 429):capacity"
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user