File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from telegram_mcp import runner
4+
5+
6+ class _FakeClient :
7+ def __init__ (self , * , authorized : bool ):
8+ self .authorized = authorized
9+ self .connected = False
10+ self .started = False
11+
12+ async def connect (self ):
13+ self .connected = True
14+
15+ async def is_user_authorized (self ):
16+ return self .authorized
17+
18+ async def start (self ):
19+ self .started = True
20+
21+
22+ @pytest .mark .asyncio
23+ async def test_connect_authorized_client_uses_existing_session_without_interactive_start ():
24+ client = _FakeClient (authorized = True )
25+
26+ await runner ._connect_authorized_client ("default" , client )
27+
28+ assert client .connected is True
29+ assert client .started is False
30+
31+
32+ @pytest .mark .asyncio
33+ async def test_connect_authorized_client_rejects_unauthorized_session ():
34+ client = _FakeClient (authorized = False )
35+
36+ with pytest .raises (RuntimeError , match = "Interactive phone login is disabled" ):
37+ await runner ._connect_authorized_client ("default" , client )
38+
39+ assert client .connected is True
40+ assert client .started is False
You can’t perform that action at this time.
0 commit comments