feat: 移除 CSV 和 Markdown 导出
This commit is contained in:
@@ -419,8 +419,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
|
||||
@@ -431,8 +433,10 @@ def test_result_pages_render_seeded_data():
|
||||
assert "<pre" not in hotspot_response.text
|
||||
assert item_response.status_code == 200
|
||||
assert "内容总结" in item_response.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
|
||||
@@ -467,14 +471,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():
|
||||
@@ -497,7 +503,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)
|
||||
|
||||
@@ -506,15 +512,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):
|
||||
@@ -610,18 +611,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):
|
||||
|
||||
Reference in New Issue
Block a user