tests/gateway/conftest.py already installs a comprehensive telegram mock at collection time (line 330), before any test module's imports run. The per-file copies were fully redundant — each was a simpler subset (plain strings, setdefault, fewer error classes) of the conftest version (which uses _fake_str_enum for PTB-faithful StrEnum semantics, sys.modules overwrite to win over partial/broken imports, and a full error hierarchy including BadRequest, Forbidden, RetryAfter, Conflict, InvalidToken). Removed: function def + module-level call + now-unused imports (sys, MagicMock where no longer referenced) + dangling comment blocks that referenced the deleted mock, in 27 test files. Left untouched: tests/gateway/conftest.py (canonical source) and tests/e2e/conftest.py (separate conftest tree that may run in isolation). Found by /simplify-code review of PR #90560.
24 lines
679 B
Python
24 lines
679 B
Python
"""Tests for Telegram document-size cap.
|
|
|
|
The public Telegram Bot API caps `getFile` at 20MB. A locally-hosted
|
|
`telegram-bot-api` server raises that ceiling to 2GB. We treat the presence
|
|
of `extra.base_url` as the explicit opt-in to the higher cap.
|
|
"""
|
|
|
|
|
|
from gateway.config import PlatformConfig
|
|
from plugins.platforms.telegram.adapter import TelegramAdapter # noqa: E402
|
|
|
|
|
|
def test_max_doc_bytes_raised_to_2gb_when_base_url_set():
|
|
adapter = TelegramAdapter(
|
|
PlatformConfig(
|
|
enabled=True,
|
|
token="***",
|
|
extra={"base_url": "http://localhost:8081/bot"},
|
|
)
|
|
)
|
|
assert adapter._max_doc_bytes == 2 * 1024 * 1024 * 1024
|
|
|
|
|