拆分Mock规则样本构造器
This commit is contained in:
@@ -9,6 +9,7 @@ from services.statement_service import StatementService
|
||||
from services.statement_rule_samples import (
|
||||
DEFAULT_LARGE_TRANSACTION_THRESHOLDS,
|
||||
build_large_transaction_seed_statements,
|
||||
build_seed_statements_for_rule_plan,
|
||||
)
|
||||
|
||||
|
||||
@@ -31,6 +32,44 @@ def test_generate_statements_should_include_seeded_samples_before_noise():
|
||||
assert any(item["userMemo"] == "购买房产首付款" for item in statements)
|
||||
|
||||
|
||||
def test_build_seed_statements_for_rule_plan_should_only_include_requested_phase1_rules():
|
||||
plan = {
|
||||
"large_transaction_hit_rules": [],
|
||||
"phase1_hit_rules": ["GAMBLING_SENSITIVE_KEYWORD", "FOREX_BUY_AMT"],
|
||||
}
|
||||
|
||||
statements = build_seed_statements_for_rule_plan(
|
||||
group_id=1000,
|
||||
log_id=20001,
|
||||
rule_plan=plan,
|
||||
)
|
||||
|
||||
assert any("游戏" in item["userMemo"] for item in statements)
|
||||
assert any("购汇" in item["userMemo"] for item in statements)
|
||||
assert not any("证券" in item["userMemo"] for item in statements)
|
||||
|
||||
|
||||
def test_build_seed_statements_for_rule_plan_should_generate_withdraw_cnt_samples():
|
||||
plan = {
|
||||
"large_transaction_hit_rules": [],
|
||||
"phase1_hit_rules": ["WITHDRAW_CNT"],
|
||||
}
|
||||
|
||||
statements = build_seed_statements_for_rule_plan(
|
||||
group_id=1000,
|
||||
log_id=20001,
|
||||
rule_plan=plan,
|
||||
)
|
||||
|
||||
assert len(
|
||||
[
|
||||
item
|
||||
for item in statements
|
||||
if "微信提现" in item["userMemo"] or "支付宝提现" in item["userMemo"]
|
||||
]
|
||||
) >= 4
|
||||
|
||||
|
||||
def test_large_transaction_seed_should_cover_all_eight_rules():
|
||||
"""大额交易样本生成器必须覆盖 8 条已实现规则的关键口径。"""
|
||||
statements = build_large_transaction_seed_statements(group_id=1000, log_id=20001)
|
||||
|
||||
Reference in New Issue
Block a user