test_v4_thresholds_per_platform.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """V4 判定/游走门槛按平台解耦:抖音 65、快手/视频号 70;配置缺失回退 70。"""
  2. from pathlib import Path
  3. from content_agent.business_modules.rule_judgment.evaluator import (
  4. _v4_allow_walk,
  5. _v4_decision,
  6. _v4_thresholds,
  7. )
  8. from content_agent.integrations.policy_json import JsonPolicyBundleStore
  9. POLICY = JsonPolicyBundleStore(Path(".")).load_policy_bundle("V4")
  10. def test_douyin_pool_at_65():
  11. th = _v4_thresholds(POLICY, "douyin")
  12. assert th["pool_total"] == 65 and th["pool_query"] == 65 and th["walk_total"] == 65
  13. assert _v4_decision({"query_relevance_score": 90, "total_score": 66}, th)[0] == "ADD_TO_CONTENT_POOL"
  14. assert _v4_decision({"query_relevance_score": 90, "total_score": 64}, th)[0] == "KEEP_CONTENT_FOR_REVIEW"
  15. assert _v4_decision({"query_relevance_score": 90, "total_score": 54}, th)[0] == "REJECT_CONTENT"
  16. def test_non_douyin_keeps_70():
  17. for plat in ("kuaishou", "shipinhao"):
  18. th = _v4_thresholds(POLICY, plat)
  19. assert th["pool_total"] == 70 and th["walk_total"] == 70
  20. assert _v4_decision({"query_relevance_score": 90, "total_score": 66}, th)[0] == "KEEP_CONTENT_FOR_REVIEW"
  21. assert _v4_decision({"query_relevance_score": 90, "total_score": 70}, th)[0] == "ADD_TO_CONTENT_POOL"
  22. def test_allow_walk_per_platform():
  23. sc = {"query_relevance_score": 65, "platform_performance_score": 65, "total_score": 65}
  24. assert _v4_allow_walk(sc, 65, _v4_thresholds(POLICY, "douyin")) is True
  25. assert _v4_allow_walk(sc, 65, _v4_thresholds(POLICY, "kuaishou")) is False # 需 70
  26. def test_missing_config_falls_back_to_70():
  27. th = _v4_thresholds({}, "douyin") # 无 score_thresholds 配置 → 回退内置字面量
  28. assert th["pool_total"] == 70 and th["review_total"] == 55 and th["walk_platform"] == 65