41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import pytest
|
|
|
|
from apps.scenarios.services import (
|
|
ScenarioNotFound,
|
|
get_scenario,
|
|
list_scenarios,
|
|
)
|
|
|
|
|
|
def test_list_scenarios_loads_five_configs():
|
|
scenarios = list_scenarios()
|
|
assert [scenario["id"] for scenario in scenarios] == [
|
|
"document_review",
|
|
"knowledge_qa",
|
|
"quality_analysis",
|
|
"risk_audit",
|
|
"ticket_assistant",
|
|
]
|
|
|
|
|
|
def test_get_scenario_returns_full_agent_config():
|
|
scenario = get_scenario("quality_analysis")
|
|
assert scenario["agent"]["role"] == "质量管理专家"
|
|
assert scenario["rag"]["enabled"] is True
|
|
assert scenario["output"]["type"] == "quality_report"
|
|
assert "质量异常分析" in scenario["applicable_questions"][0]
|
|
|
|
|
|
def test_get_scenario_raises_clear_error_for_missing_id():
|
|
with pytest.raises(ScenarioNotFound, match="场景不存在"):
|
|
get_scenario("missing")
|
|
|
|
|
|
def test_home_page_shows_applicable_questions(client):
|
|
response = client.get("/")
|
|
|
|
content = response.content.decode("utf-8")
|
|
assert response.status_code == 200
|
|
assert "适用题型" in content
|
|
assert "SOP 问答" in content
|