Files
LangBot/tests/unit_tests/test_telemetry.py
T
2026-07-29 11:32:26 +08:00

30 lines
729 B
Python

from __future__ import annotations
from types import SimpleNamespace
import asyncio
import pytest
from langbot.pkg.telemetry.telemetry import TelemetryManager
@pytest.mark.asyncio
async def test_send_tasks_are_scoped_to_manager_instance(monkeypatch):
async def fake_send(self, payload):
return payload
monkeypatch.setattr(TelemetryManager, 'send', fake_send)
first = TelemetryManager(SimpleNamespace())
second = TelemetryManager(SimpleNamespace())
assert first.send_tasks is not second.send_tasks
await first.start_send_task({'event': 'first'})
task = first.send_tasks[0]
await task
await asyncio.sleep(0)
assert first.send_tasks == []
assert second.send_tasks == []