|
23 | 23 | from telegram_mcp.tools import chats, messages |
24 | 24 |
|
25 | 25 |
|
| 26 | +@pytest.fixture(autouse=True) |
| 27 | +def _reset_chat_allowlist_global_state(monkeypatch): |
| 28 | + monkeypatch.delenv("TELEGRAM_ALLOWED_CHAT_IDS", raising=False) |
| 29 | + monkeypatch.setattr(runtime, "ALLOWED_CHAT_IDS", None) |
| 30 | + if hasattr(main, "ALLOWED_CHAT_IDS"): |
| 31 | + monkeypatch.setattr(main, "ALLOWED_CHAT_IDS", None) |
| 32 | + yield |
| 33 | + monkeypatch.delenv("TELEGRAM_ALLOWED_CHAT_IDS", raising=False) |
| 34 | + monkeypatch.setattr(runtime, "ALLOWED_CHAT_IDS", None) |
| 35 | + if hasattr(main, "ALLOWED_CHAT_IDS"): |
| 36 | + monkeypatch.setattr(main, "ALLOWED_CHAT_IDS", None) |
| 37 | + |
| 38 | + |
26 | 39 | class FakeDialog: |
27 | 40 | def __init__(self, entity, unread_count=0, archived=False): |
28 | 41 | self.entity = entity |
@@ -357,6 +370,7 @@ async def test_create_poll_blocks_unallowed_chat(monkeypatch): |
357 | 370 | def test_main_compatibility_aliases(monkeypatch): |
358 | 371 | monkeypatch.delenv("TELEGRAM_ALLOWED_CHAT_IDS", raising=False) |
359 | 372 | monkeypatch.setattr(main, "ALLOWED_CHAT_IDS", None) |
| 373 | + monkeypatch.setattr(runtime, "ALLOWED_CHAT_IDS", None) |
360 | 374 |
|
361 | 375 | assert not main.is_chat_allowlist_enabled() |
362 | 376 |
|
|
0 commit comments