test_query_next_page_removed.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """M8E:query_next_page 边全链路无残留——硬编码集合 2 边、图 9 边、profile/源码/前端无残留。"""
  2. import json
  3. from pathlib import Path
  4. from content_agent.business_modules import walk_engine
  5. from content_agent.integrations.walk_graph_json import WalkGraphStore
  6. from scripts.validate_v4_config_contract import M4_WALK_GATE_EDGES
  7. ROOT = Path(__file__).resolve().parents[1]
  8. _TWO_EDGES = {"hashtag_to_query", "author_to_works"}
  9. def test_hardcoded_gate_edge_sets_are_two_edges():
  10. # 删边的"必崩点":四处硬编码集合必须全是 2 边(不含 query_next_page)。
  11. assert walk_engine.V4_WALK_GATE_EDGES == _TWO_EDGES
  12. assert M4_WALK_GATE_EDGES == _TWO_EDGES
  13. def test_walk_graph_has_no_query_next_page_edge():
  14. graph = WalkGraphStore().load_graph()
  15. edge_ids = {edge["edge_id"] for edge in graph["edges"]}
  16. assert "query_next_page" not in edge_ids
  17. def test_walk_policy_gate_applies_to_two_edges():
  18. policy = WalkGraphStore().load_policy()
  19. gate = policy.get("v4_walk_gate") or {}
  20. assert set(gate.get("applies_to_edges") or []) == _TWO_EDGES
  21. def test_platform_profiles_have_no_query_next_page():
  22. profile_dir = ROOT / "tech_documents" / "数据接口与来源" / "platform_profiles"
  23. for path in profile_dir.glob("*.json"):
  24. data = json.loads(path.read_text(encoding="utf-8"))
  25. assert "query_next_page" not in json.dumps(data), f"{path.name} still references query_next_page"
  26. def test_engine_and_frontend_source_have_no_query_next_page():
  27. for rel in [
  28. "content_agent/business_modules/walk_engine.py",
  29. "content_agent/flow_ledger_service.py",
  30. "content_agent/dashboard_service.py",
  31. ]:
  32. text = (ROOT / rel).read_text(encoding="utf-8")
  33. assert "query_next_page" not in text, f"{rel} still references query_next_page"