mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-15 14:06:41 +03:00
4b2d252fe1
Sure wish I would've automated this.
31 lines
747 B
Python
31 lines
747 B
Python
import os
|
|
import random
|
|
|
|
from pytest import mark
|
|
from telethon import Client, Config, Session
|
|
from telethon import _tl as tl
|
|
|
|
|
|
@mark.api
|
|
@mark.net
|
|
async def test_ping_pong() -> None:
|
|
api_id = os.getenv("TG_ID")
|
|
api_hash = os.getenv("TG_HASH")
|
|
assert api_id and api_id.isdigit()
|
|
assert api_hash
|
|
client = Client(
|
|
Config(
|
|
session=Session(),
|
|
api_id=int(api_id),
|
|
api_hash=api_hash,
|
|
)
|
|
)
|
|
assert not client.connected
|
|
await client.connect()
|
|
assert client.connected
|
|
|
|
ping_id = random.randrange(-(2**63), 2**63)
|
|
pong = await client(tl.mtproto.functions.ping(ping_id=ping_id))
|
|
assert isinstance(pong, tl.mtproto.types.Pong)
|
|
assert pong.ping_id == ping_id
|