|
|
@@ -67,6 +67,14 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
"search_query_generation_method": "tag_query",
|
|
|
"raw_payload": {"parent_search_query_id": "q_001", "hashtag": "肩颈放松"},
|
|
|
},
|
|
|
+ {
|
|
|
+ "run_id": run_id,
|
|
|
+ "policy_run_id": policy_run_id,
|
|
|
+ "search_query_id": "q_001_page_002",
|
|
|
+ "search_query": "睡前拉伸",
|
|
|
+ "search_query_generation_method": "query_next_page",
|
|
|
+ "raw_payload": {"parent_search_query_id": "q_001"},
|
|
|
+ },
|
|
|
{
|
|
|
"run_id": run_id,
|
|
|
"policy_run_id": policy_run_id,
|
|
|
@@ -155,6 +163,19 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
"statistics": {},
|
|
|
"raw_payload": {},
|
|
|
},
|
|
|
+ {
|
|
|
+ "run_id": run_id,
|
|
|
+ "policy_run_id": policy_run_id,
|
|
|
+ "content_discovery_id": "content_004",
|
|
|
+ "platform_content_id": "douyin_004",
|
|
|
+ "search_query_id": "q_001_page_002",
|
|
|
+ "previous_discovery_step": "query_next_page",
|
|
|
+ "platform": "douyin",
|
|
|
+ "description": "翻页搜到的视频",
|
|
|
+ "author_display_name": "拉伸助手",
|
|
|
+ "statistics": {},
|
|
|
+ "raw_payload": {},
|
|
|
+ },
|
|
|
],
|
|
|
)
|
|
|
service.runtime.append_jsonl(
|
|
|
@@ -261,7 +282,29 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
"platform_performance_score": 74,
|
|
|
},
|
|
|
"raw_payload": {},
|
|
|
- }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "run_id": run_id,
|
|
|
+ "policy_run_id": policy_run_id,
|
|
|
+ "walk_action_id": "walk_page_001",
|
|
|
+ "edge_id": "query_next_page",
|
|
|
+ "depth": 1,
|
|
|
+ "from_node_type": "SearchQuery",
|
|
|
+ "from_node_id": "q_001",
|
|
|
+ "to_node_type": "SearchQuery",
|
|
|
+ "to_node_id": "q_001_page_002",
|
|
|
+ "decision_id": "decision_001",
|
|
|
+ "walk_status": "success",
|
|
|
+ "walk_action": "fetch_next_page",
|
|
|
+ "page_cursor": "10",
|
|
|
+ "reason_code": "v4_query_and_platform_pass",
|
|
|
+ "walk_gate_snapshot": {
|
|
|
+ "score": 82,
|
|
|
+ "query_relevance_score": 90,
|
|
|
+ "platform_performance_score": 74,
|
|
|
+ },
|
|
|
+ "raw_payload": {},
|
|
|
+ },
|
|
|
],
|
|
|
)
|
|
|
service.runtime.write_json(
|
|
|
@@ -283,7 +326,7 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
assert ledger["data_origin_label"] == "本地调试缓存"
|
|
|
assert len(ledger["rows"]) == 3
|
|
|
assert ledger["summary"]["first_round_query_count"] == 3
|
|
|
- assert ledger["summary"]["extension_query_count"] == 1
|
|
|
+ assert ledger["summary"]["extension_query_count"] == 2
|
|
|
row = next(item for item in ledger["rows"] if item["id"] == "q_001")
|
|
|
assert row["query"]["method_label"] == "Pattern 种子词"
|
|
|
assert row["source"]["details"] == ["需求单号:demand_123", "种子词:睡前拉伸", "来源帖子:seed_001"]
|
|
|
@@ -316,8 +359,8 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
assert videos["videos"][0]["oss_url"] == "https://oss.example.com/video.mp4"
|
|
|
|
|
|
walk = client.get(f"/runs/{run_id}/flow-ledger/queries/q_001/walk").json()
|
|
|
- assert walk["summary"]["total_actions"] == 1
|
|
|
- assert walk["summary"]["extension_query_count"] == 1
|
|
|
+ assert walk["summary"]["total_actions"] == 2
|
|
|
+ assert walk["summary"]["extension_query_count"] == 2
|
|
|
assert walk["lanes"]["tag_query"][0]["edge_label"] == "从视频标签继续游走"
|
|
|
assert walk["lanes"]["tag_query"][0]["source_video"]["title"] == "睡前 5 分钟肩颈拉伸"
|
|
|
assert walk["lanes"]["tag_query"][0]["trigger_label"] == "标签:#拉伸"
|
|
|
@@ -326,6 +369,13 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
|
|
|
assert "起点:从视频《睡前 5 分钟肩颈拉伸》触发" in walk["lanes"]["tag_query"][0]["detail_lines"]
|
|
|
assert "结果:已生成标签搜索词《肩颈放松》,带回 1 条视频。" in walk["lanes"]["tag_query"][0]["detail_lines"]
|
|
|
assert walk["lanes"]["tag_query"][0]["score_items"][0]["score_label"] == "82 分"
|
|
|
+ page_action = walk["lanes"]["query_next_page"][0]
|
|
|
+ assert page_action["edge_label"] == "翻页继续找"
|
|
|
+ assert page_action["source_video"] is None
|
|
|
+ assert page_action["from_label"] == "从搜索词《睡前拉伸》继续"
|
|
|
+ assert page_action["target_query"]["id"] == "q_001_page_002"
|
|
|
+ assert page_action["target_videos"][0]["title"] == "翻页搜到的视频"
|
|
|
+ assert "起点:从搜索词《睡前拉伸》继续" in page_action["detail_lines"]
|
|
|
|
|
|
detail = client.get(f"/runs/{run_id}/flow-ledger/videos/douyin_001").json()
|
|
|
assert detail["video"]["playable_url"] == "https://oss.example.com/video.mp4"
|