| 123456789101112131415161718192021222324252627282930313233343536373839 |
- """V4 判定/游走门槛按平台解耦:抖音 65、快手/视频号 70;配置缺失回退 70。"""
- from pathlib import Path
- from content_agent.business_modules.rule_judgment.evaluator import (
- _v4_allow_walk,
- _v4_decision,
- _v4_thresholds,
- )
- from content_agent.integrations.policy_json import JsonPolicyBundleStore
- POLICY = JsonPolicyBundleStore(Path(".")).load_policy_bundle("V4")
- def test_douyin_pool_at_65():
- th = _v4_thresholds(POLICY, "douyin")
- assert th["pool_total"] == 65 and th["pool_query"] == 65 and th["walk_total"] == 65
- assert _v4_decision({"query_relevance_score": 90, "total_score": 66}, th)[0] == "ADD_TO_CONTENT_POOL"
- assert _v4_decision({"query_relevance_score": 90, "total_score": 64}, th)[0] == "KEEP_CONTENT_FOR_REVIEW"
- assert _v4_decision({"query_relevance_score": 90, "total_score": 54}, th)[0] == "REJECT_CONTENT"
- def test_non_douyin_keeps_70():
- for plat in ("kuaishou", "shipinhao"):
- th = _v4_thresholds(POLICY, plat)
- assert th["pool_total"] == 70 and th["walk_total"] == 70
- assert _v4_decision({"query_relevance_score": 90, "total_score": 66}, th)[0] == "KEEP_CONTENT_FOR_REVIEW"
- assert _v4_decision({"query_relevance_score": 90, "total_score": 70}, th)[0] == "ADD_TO_CONTENT_POOL"
- def test_allow_walk_per_platform():
- sc = {"query_relevance_score": 65, "platform_performance_score": 65, "total_score": 65}
- assert _v4_allow_walk(sc, 65, _v4_thresholds(POLICY, "douyin")) is True
- assert _v4_allow_walk(sc, 65, _v4_thresholds(POLICY, "kuaishou")) is False # 需 70
- def test_missing_config_falls_back_to_70():
- th = _v4_thresholds({}, "douyin") # 无 score_thresholds 配置 → 回退内置字面量
- assert th["pool_total"] == 70 and th["review_total"] == 55 and th["walk_platform"] == 65
|