mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added fields to Chat
This commit is contained in:
parent
de3c5c1a8d
commit
864b511a16
3 changed files with 110 additions and 0 deletions
43
tests/test_api/test_types/test_chat.py
Normal file
43
tests/test_api/test_types/test_chat.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.types import Chat
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class TestChat:
|
||||
@pytest.mark.parametrize(
|
||||
"chat_type,title,first_name,last_name,result",
|
||||
[
|
||||
["private", None, 'name', None, 'name'],
|
||||
["private", None, 'name', 'surname', 'name surname'],
|
||||
["supergroup", 'Chat title', None, None, 'Chat title']
|
||||
]
|
||||
)
|
||||
def test_full_name(self, chat_type: Optional[str], title: Optional[str], first_name: Optional[str],
|
||||
last_name: Optional[str], result):
|
||||
chat = Chat(id=0, type=chat_type, title=title, first_name=first_name, last_name=last_name)
|
||||
assert chat.full_name == result
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"chat_type,title,first_name,last_name,username,result",
|
||||
[
|
||||
["private", None, 'name', None, None, 'name'],
|
||||
["supergroup", None, 'name', None, None, None],
|
||||
["private", None, 'name', None, 'user', '@user'],
|
||||
["supergroup", None, 'name', None, 'user', '@user']
|
||||
]
|
||||
)
|
||||
def test_mention(self, chat_type: Optional[str], title: Optional[str], first_name: Optional[str],
|
||||
last_name: Optional[str], username: Optional[str], result):
|
||||
chat = Chat(id=0, type=chat_type, title=title, first_name=first_name, last_name=last_name, username=username)
|
||||
assert chat.mention == result
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"chat_type,chat_id,result",
|
||||
[
|
||||
["private", 123124123, 'tg://user?id=123124123']
|
||||
]
|
||||
)
|
||||
def test_user_url(self, chat_type: Optional[str], chat_id: int, result):
|
||||
chat = Chat(type=chat_type, id=chat_id)
|
||||
assert chat.user_url == result
|
||||
Loading…
Add table
Add a link
Reference in a new issue