修复风控时间口径与Agent截断提示
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from app.model.fund import FundRiskAlert
|
||||
from app.service.risk_notification_service import RiskNotificationService
|
||||
|
||||
@@ -77,3 +79,47 @@ def test_high_risk_batch_creates_in_app_and_mail_records() -> None:
|
||||
|
||||
assert len(records) == 2
|
||||
assert {record.channel for record in records} == {"站内提醒", "邮件"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_notification_list_interprets_time_as_local_time(monkeypatch) -> None:
|
||||
from app.api.schemas.risk import RiskNotificationPageQuery
|
||||
from app.core.contracts import RequestContext
|
||||
from app.repository.fund_query_repository import FundPage
|
||||
|
||||
captured: dict = {}
|
||||
|
||||
class StubRepository:
|
||||
def __init__(self, _session, *, scope) -> None:
|
||||
self.scope = scope
|
||||
|
||||
async def list_notifications(self, **kwargs) -> FundPage:
|
||||
captured.update(kwargs)
|
||||
return FundPage(
|
||||
entity="risk_notification",
|
||||
items=(),
|
||||
limit=10,
|
||||
offset=0,
|
||||
next_offset=None,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.service.risk_notification_service.RiskRepository",
|
||||
StubRepository,
|
||||
)
|
||||
service = RiskNotificationService(object())
|
||||
query = RiskNotificationPageQuery(
|
||||
start_time=datetime(2026, 9, 10, 12, 0),
|
||||
end_time=datetime(2026, 9, 10, 13, 0),
|
||||
)
|
||||
context = RequestContext(
|
||||
user_id="990000002",
|
||||
trace_id="trace",
|
||||
permissions=("risk:alert:read",),
|
||||
data_scope="all",
|
||||
)
|
||||
|
||||
await service.list_notifications(context, query)
|
||||
|
||||
assert captured["start_time"] == datetime(2026, 9, 10, 4, 0)
|
||||
assert captured["end_time"] == datetime(2026, 9, 10, 5, 0)
|
||||
|
||||
Reference in New Issue
Block a user