feat: add QR login and browser-backed web tools

This commit is contained in:
Azimkin
2026-09-14 14:19:20 +02:00
parent 3a8c198caa
commit b68e715267
19 changed files with 2740 additions and 8 deletions

37
tests/test_manager_qr.py Normal file
View File

@@ -0,0 +1,37 @@
from __future__ import annotations
import tempfile
import unittest
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock, patch
from app.config import AccountConfig, AppConfig
from app.manager import AccountManager
class AccountManagerQrTests(unittest.IsolatedAsyncioTestCase):
async def test_qr_flag_is_passed_when_starting_account(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
config = AppConfig(
api_id=123456,
api_hash="hash",
session_dir=Path(temp_dir),
accounts=[AccountConfig(name="personal", session="personal", use_qr=True)],
)
manager = AccountManager(config)
client = MagicMock()
client.start = AsyncMock()
client.get_me = AsyncMock(return_value=MagicMock(id=42))
with (
patch.object(AccountManager, "_make_client", return_value=client),
patch("app.manager.register_common_handlers"),
):
await manager.start_account(manager.states[0])
client.start.assert_awaited_once_with(use_qr=True)
self.assertEqual(manager.states[0].status, "running")
if __name__ == "__main__":
unittest.main()