修复风控时间口径与Agent截断提示

This commit is contained in:
zhangshy
2026-09-11 15:25:45 +08:00
parent 5102eaac64
commit d2cdbbac01
24 changed files with 318 additions and 27 deletions
@@ -52,6 +52,28 @@ class FakeRepository:
return None
class RecordingRepository(FakeRepository):
def __init__(self) -> None:
super().__init__()
self.calls: list[tuple[str, dict]] = []
async def list_transactions(self, **kwargs) -> FundPage:
self.calls.append(("transactions", kwargs))
return self.page
async def list_capital_flows(self, **kwargs) -> FundPage:
self.calls.append(("capital_flows", kwargs))
return self.page
async def list_login_records(self, **kwargs) -> FundPage:
self.calls.append(("login_records", kwargs))
return self.page
async def list_notifications(self, **kwargs) -> FundPage:
self.calls.append(("notifications", kwargs))
return self.page
def context(**updates) -> RequestContext:
values = {
"user_id": "990000002",
@@ -163,3 +185,23 @@ async def test_missing_alert_detail_is_hidden() -> None:
with pytest.raises(GenericResourceNotFoundError):
await service.get_alert_detail(context(), "ALERT-NOT-FOUND")
@pytest.mark.asyncio
@pytest.mark.parametrize(
"source",
("transactions", "capital_flows", "login_records", "notifications"),
)
async def test_evidence_time_filters_are_interpreted_as_local_time(source: str) -> None:
repository = RecordingRepository()
service = RiskQueryService(None, repository=repository)
query = RiskEvidencePageQuery(
start_time=datetime(2026, 9, 10, 12, 0),
end_time=datetime(2026, 9, 10, 13, 0),
)
await service.list_evidence(context(), source, query)
assert repository.calls[0][0] == source
assert repository.calls[0][1]["start_time"] == datetime(2026, 9, 10, 4, 0)
assert repository.calls[0][1]["end_time"] == datetime(2026, 9, 10, 5, 0)