mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-10 03:22:05 +00:00
fix(msgraph): bound webhook receipt dedupe cache
This commit is contained in:
parent
46a6f39024
commit
2a215de9af
2 changed files with 56 additions and 2 deletions
|
|
@ -185,3 +185,41 @@ class TestMSGraphNotifications:
|
|||
await asyncio.sleep(0.05)
|
||||
|
||||
assert len(scheduled) == 1
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_seen_receipts_are_bounded(self):
|
||||
adapter = _make_adapter(max_seen_receipts=2)
|
||||
|
||||
async def _capture(notification, event):
|
||||
return None
|
||||
|
||||
adapter.set_notification_scheduler(_capture)
|
||||
|
||||
async def _post(notification_id: str):
|
||||
payload = {
|
||||
"value": [
|
||||
{
|
||||
"id": notification_id,
|
||||
"subscriptionId": "sub-1",
|
||||
"changeType": "updated",
|
||||
"resource": "communications/onlineMeetings/meeting-3",
|
||||
"clientState": "expected-client-state",
|
||||
}
|
||||
]
|
||||
}
|
||||
return await adapter._handle_notification(_FakeRequest(json_payload=payload))
|
||||
|
||||
first = await _post("notif-a")
|
||||
second = await _post("notif-b")
|
||||
third = await _post("notif-c")
|
||||
|
||||
assert first.status == 202
|
||||
assert second.status == 202
|
||||
assert third.status == 202
|
||||
assert len(adapter._seen_receipts) == 2
|
||||
assert list(adapter._seen_receipt_order) == ["id:notif-b", "id:notif-c"]
|
||||
|
||||
replay = await _post("notif-a")
|
||||
replay_data = json.loads(replay.text)
|
||||
assert replay_data["accepted"] == 1
|
||||
assert replay_data["duplicates"] == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue