mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added message_thread_id to url of chats with topics for message.get_u… (#1469)
* Added message_thread_id to url of chats with topics for message.get_url() (#1451) * Added tests for message.get_url() * Added tests for message.get_url() * Changed tests for message.get_url()
This commit is contained in:
parent
9b0b6a68ed
commit
e2e1bc5573
3 changed files with 69 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ class TestGetMessageUrl:
|
|||
["supergroup", -10012345678901, None, True, "https://t.me/c/12345678901/10"],
|
||||
],
|
||||
)
|
||||
def test_method(
|
||||
def test_get_url_non_topic_message(
|
||||
self,
|
||||
bot: MockedBot,
|
||||
chat_type: str,
|
||||
|
|
@ -46,5 +46,61 @@ class TestGetMessageUrl:
|
|||
|
||||
if expected_result is None:
|
||||
assert fake_message.get_url(force_private=force_private) is None
|
||||
assert (
|
||||
fake_message.get_url(force_private=force_private, include_thread_id=True) is None
|
||||
)
|
||||
else:
|
||||
assert fake_message.get_url(force_private=force_private) == expected_result
|
||||
assert (
|
||||
fake_message.get_url(force_private=force_private, include_thread_id=True)
|
||||
== expected_result
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"chat_username,force_private,include_thread_id,fake_thread_id_topic,expected_result",
|
||||
[
|
||||
[None, False, False, None, "https://t.me/c/1234567890/10"],
|
||||
[None, False, False, 3, "https://t.me/c/1234567890/10"],
|
||||
[None, False, True, None, "https://t.me/c/1234567890/10"],
|
||||
[None, False, True, 3, "https://t.me/c/1234567890/3/10"],
|
||||
[None, True, False, None, "https://t.me/c/1234567890/10"],
|
||||
[None, True, False, 3, "https://t.me/c/1234567890/10"],
|
||||
[None, True, True, None, "https://t.me/c/1234567890/10"],
|
||||
[None, True, True, 3, "https://t.me/c/1234567890/3/10"],
|
||||
["name", False, False, None, "https://t.me/name/10"],
|
||||
["name", False, False, 3, "https://t.me/name/10"],
|
||||
["name", False, True, None, "https://t.me/name/10"],
|
||||
["name", False, True, 3, "https://t.me/name/3/10"],
|
||||
["name", True, False, None, "https://t.me/c/1234567890/10"],
|
||||
["name", True, False, 3, "https://t.me/c/1234567890/10"],
|
||||
["name", True, True, None, "https://t.me/c/1234567890/10"],
|
||||
["name", True, True, 3, "https://t.me/c/1234567890/3/10"],
|
||||
],
|
||||
)
|
||||
def test_get_url_if_topic_message(
|
||||
self,
|
||||
bot: MockedBot,
|
||||
chat_username: Optional[str],
|
||||
force_private: bool,
|
||||
include_thread_id: bool,
|
||||
fake_thread_id_topic: Optional[int],
|
||||
expected_result: Optional[str],
|
||||
):
|
||||
fake_message_id = 10
|
||||
fake_chat_id = -1001234567890
|
||||
fake_chat_type = "supergroup"
|
||||
fake_chat_with_topics = Chat(
|
||||
id=fake_chat_id, username=chat_username, type=fake_chat_type, is_forum=True
|
||||
)
|
||||
fake_message_from_topic = Message(
|
||||
message_id=fake_message_id,
|
||||
date=datetime.datetime.now(),
|
||||
text="test",
|
||||
chat=fake_chat_with_topics,
|
||||
is_topic_message=True,
|
||||
message_thread_id=fake_thread_id_topic,
|
||||
)
|
||||
actual_result = fake_message_from_topic.get_url(
|
||||
force_private=force_private, include_thread_id=include_thread_id
|
||||
)
|
||||
assert actual_result == expected_result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue