实现lsfx-mock全命中SQL对齐
This commit is contained in:
@@ -215,6 +215,35 @@ def test_build_rule_hit_plan_should_return_all_compatible_rules_in_all_mode(monk
|
||||
assert plan["phase2_baseline_hit_rules"] == PHASE2_BASELINE_RULE_CODES
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_keep_sql_aligned_target_rules_in_all_mode(monkeypatch):
|
||||
monkeypatch.setattr("services.file_service.settings.RULE_HIT_MODE", "all")
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
|
||||
plan = service._build_rule_hit_plan(10001)
|
||||
|
||||
assert "SPECIAL_AMOUNT_TRANSACTION" in plan["phase1_hit_rules"]
|
||||
assert "SUSPICIOUS_INCOME_KEYWORD" in plan["phase1_hit_rules"]
|
||||
assert "LOW_INCOME_RELATIVE_LARGE_TRANSACTION" in plan["phase2_statement_hit_rules"]
|
||||
assert "MONTHLY_FIXED_INCOME" in plan["phase2_statement_hit_rules"]
|
||||
assert "FIXED_COUNTERPARTY_TRANSFER" in plan["phase2_statement_hit_rules"]
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_not_include_placeholder_rules_in_all_mode(monkeypatch):
|
||||
monkeypatch.setattr("services.file_service.settings.RULE_HIT_MODE", "all")
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
|
||||
plan = service._build_rule_hit_plan(10001)
|
||||
all_rule_codes = {
|
||||
*plan["large_transaction_hit_rules"],
|
||||
*plan["phase1_hit_rules"],
|
||||
*plan["phase2_statement_hit_rules"],
|
||||
*plan["phase2_baseline_hit_rules"],
|
||||
}
|
||||
|
||||
assert "ABNORMAL_CUSTOMER_TRANSACTION" not in all_rule_codes
|
||||
assert "INTEREST_PAYMENT_BY_OTHERS" not in all_rule_codes
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_keep_subset_mode_as_default():
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
|
||||
@@ -317,3 +346,38 @@ def test_fetch_inner_flow_should_persist_phase2_rule_hit_plan(monkeypatch):
|
||||
"HOUSE_REGISTRATION_MISMATCH",
|
||||
"SUPPLIER_CONCENTRATION",
|
||||
]
|
||||
|
||||
|
||||
def test_fetch_inner_flow_should_apply_low_income_baseline_in_all_mode(monkeypatch):
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
applied = {}
|
||||
|
||||
def fake_apply(**kwargs):
|
||||
applied["baseline_rule_codes"] = kwargs["baseline_rule_codes"]
|
||||
|
||||
monkeypatch.setattr("services.file_service.settings.RULE_HIT_MODE", "all")
|
||||
monkeypatch.setattr(service.phase2_baseline_service, "apply", fake_apply)
|
||||
monkeypatch.setattr(
|
||||
service,
|
||||
"_build_rule_hit_plan",
|
||||
lambda log_id: {
|
||||
"large_transaction_hit_rules": [],
|
||||
"phase1_hit_rules": [],
|
||||
"phase2_statement_hit_rules": ["LOW_INCOME_RELATIVE_LARGE_TRANSACTION"],
|
||||
"phase2_baseline_hit_rules": [],
|
||||
},
|
||||
)
|
||||
|
||||
service.fetch_inner_flow(
|
||||
{
|
||||
"groupId": 1001,
|
||||
"customerNo": "test_customer_low_income",
|
||||
"dataChannelCode": "test_code",
|
||||
"requestDateId": 20240101,
|
||||
"dataStartDateId": 20240101,
|
||||
"dataEndDateId": 20240131,
|
||||
"uploadUserId": 902001,
|
||||
}
|
||||
)
|
||||
|
||||
assert applied["baseline_rule_codes"] == ["LOW_INCOME_RELATIVE_LARGE_TRANSACTION"]
|
||||
|
||||
Reference in New Issue
Block a user