补充Mock全部兼容规则命中计划
This commit is contained in:
@@ -8,7 +8,14 @@ import io
|
||||
from fastapi import BackgroundTasks
|
||||
from fastapi.datastructures import UploadFile
|
||||
|
||||
from services.file_service import FileRecord, FileService
|
||||
from services.file_service import (
|
||||
LARGE_TRANSACTION_RULE_CODES,
|
||||
PHASE1_RULE_CODES,
|
||||
PHASE2_BASELINE_RULE_CODES,
|
||||
PHASE2_STATEMENT_RULE_CODES,
|
||||
FileRecord,
|
||||
FileService,
|
||||
)
|
||||
|
||||
|
||||
class FakeStaffIdentityRepository:
|
||||
@@ -196,6 +203,44 @@ def test_phase2_rule_hit_plan_should_be_deterministic_for_same_log_id():
|
||||
assert 2 <= len(plan1["phase2_baseline_hit_rules"]) <= 4
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_return_all_compatible_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 plan["large_transaction_hit_rules"] == LARGE_TRANSACTION_RULE_CODES
|
||||
assert plan["phase1_hit_rules"] == PHASE1_RULE_CODES
|
||||
assert plan["phase2_statement_hit_rules"] == PHASE2_STATEMENT_RULE_CODES
|
||||
assert plan["phase2_baseline_hit_rules"] == PHASE2_BASELINE_RULE_CODES
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_keep_subset_mode_as_default():
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
|
||||
plan1 = service._build_rule_hit_plan(10001)
|
||||
plan2 = service._build_rule_hit_plan(10001)
|
||||
|
||||
assert plan1 == plan2
|
||||
assert 2 <= len(plan1["large_transaction_hit_rules"]) <= 4
|
||||
|
||||
|
||||
def test_build_rule_hit_plan_should_drop_conflicting_rules_from_all_mode(monkeypatch):
|
||||
monkeypatch.setattr("services.file_service.settings.RULE_HIT_MODE", "all")
|
||||
monkeypatch.setattr(
|
||||
"services.file_service.RULE_CONFLICT_GROUPS",
|
||||
[["SALARY_QUICK_TRANSFER", "SALARY_UNUSED"]],
|
||||
)
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
|
||||
plan = service._build_rule_hit_plan(10001)
|
||||
|
||||
assert not (
|
||||
"SALARY_QUICK_TRANSFER" in plan["phase2_statement_hit_rules"]
|
||||
and "SALARY_UNUSED" in plan["phase2_statement_hit_rules"]
|
||||
)
|
||||
|
||||
|
||||
def test_fetch_inner_flow_should_persist_rule_hit_plan(monkeypatch):
|
||||
service = FileService(staff_identity_repository=FakeStaffIdentityRepository())
|
||||
monkeypatch.setattr(
|
||||
|
||||
Reference in New Issue
Block a user