merge: 合并移除导出功能分支

# Conflicts:
#	tests/integration/test_routes.py
This commit is contained in:
meijiali
2026-07-03 19:28:59 +08:00
9 changed files with 31 additions and 289 deletions
+21 -32
View File
@@ -422,8 +422,10 @@ def test_result_pages_render_seeded_data():
assert 'onclick="window.location.reload()"' in task_response.text
assert hotspot_response.status_code == 200
assert "热点总结" in hotspot_response.text
assert "downloadExport('/api/export/hotspots/hot-result.md'" in hotspot_response.text
assert "downloadExport('/api/export/hotspots/hot-result/comments.csv'" in hotspot_response.text
assert "downloadExport(" not in hotspot_response.text
assert "/api/export/" not in hotspot_response.text
assert "导出 Markdown" not in hotspot_response.text
assert "导出热点评论 CSV" not in hotspot_response.text
assert "评论样本" in hotspot_response.text
assert "关联内容" in hotspot_response.text
assert "正向" in hotspot_response.text
@@ -437,8 +439,10 @@ def test_result_pages_render_seeded_data():
item_visible_text = BeautifulSoup(item_response.text, "html.parser").get_text(" ")
assert "热点 1:热点标题" in item_visible_text
assert "#" not in item_visible_text
assert "downloadExport('/api/export/items/item-result.md'" in item_response.text
assert "downloadExport('/api/export/items/item-result/comments.csv'" in item_response.text
assert "downloadExport(" not in item_response.text
assert "/api/export/" not in item_response.text
assert "导出 Markdown" not in item_response.text
assert "导出评论 CSV" not in item_response.text
assert "评论样本" in item_response.text
assert "Top 标签" in item_response.text
assert "评论内容" in item_response.text
@@ -473,14 +477,16 @@ def test_report_pages_render_empty_state_when_report_missing():
assert hotspot_response.status_code == 200
assert "报告生成中,请稍候" in hotspot_response.text
assert 'title="报告尚未生成"' in hotspot_response.text
assert "Markdown 报告将在分析完成后开放下载" in hotspot_response.text
assert "downloadExport('/api/export/hotspots/hot-no-report/comments.csv'" in hotspot_response.text
assert 'title="报告尚未生成"' not in hotspot_response.text
assert "Markdown 报告将在分析完成后开放下载" not in hotspot_response.text
assert "downloadExport(" not in hotspot_response.text
assert "/api/export/" not in hotspot_response.text
assert item_response.status_code == 200
assert "报告生成中,请稍候" in item_response.text
assert 'title="报告尚未生成"' in item_response.text
assert "Markdown 报告将在分析完成后开放下载" in item_response.text
assert "downloadExport('/api/export/items/item-no-report/comments.csv'" in item_response.text
assert 'title="报告尚未生成"' not in item_response.text
assert "Markdown 报告将在分析完成后开放下载" not in item_response.text
assert "downloadExport(" not in item_response.text
assert "/api/export/" not in item_response.text
def test_report_pages_warn_when_ai_sample_is_insufficient():
@@ -503,7 +509,7 @@ def test_report_pages_warn_when_ai_sample_is_insufficient():
assert "当前有效评论样本不足" in item_response.text
def test_export_routes_return_csv_and_markdown():
def test_export_routes_are_removed():
with make_test_client() as (client, engine):
seed_result_data(engine)
@@ -512,15 +518,10 @@ def test_export_routes_return_csv_and_markdown():
hotspot_md = client.get("/api/export/hotspots/hot-result.md")
item_md = client.get("/api/export/items/item-result.md")
assert csv_response.status_code == 200
assert csv_response.content.startswith(b"\xef\xbb\xbf")
assert "评论内容".encode("utf-8") in csv_response.content
assert hotspot_csv_response.status_code == 200
assert "评论内容".encode("utf-8") in hotspot_csv_response.content
assert hotspot_md.status_code == 200
assert "热点总结" in hotspot_md.text
assert item_md.status_code == 200
assert "内容总结" in item_md.text
assert csv_response.status_code == 404
assert hotspot_csv_response.status_code == 404
assert hotspot_md.status_code == 404
assert item_md.status_code == 404
def test_api_tasks_returns_service_unavailable_when_database_has_io_error(monkeypatch):
@@ -616,18 +617,6 @@ def test_item_detail_page_shows_database_error_state_when_database_has_io_error(
assert "数据库暂时不可用" in response.text
def test_export_route_returns_service_unavailable_when_database_has_io_error(monkeypatch):
def broken_export(_session, _item_id):
raise OperationalError("SELECT 1", {}, Exception("disk I/O error"))
monkeypatch.setattr("app.main.export_item_comments_csv", broken_export)
with make_test_client() as (client, _engine):
response = client.get("/api/export/items/item-io/comments.csv")
assert response.status_code == 503
assert response.json()["detail"] == "数据库暂时不可用,请稍后重试或联系维护者恢复数据。"
def test_missing_html_pages_render_friendly_not_found_page():
with make_test_client() as (client, _engine):