Improve Fixture Usage in test_message.py (#4431)

This commit is contained in:
Palaptin 2024-08-19 16:14:01 +02:00 committed by GitHub
parent 3017bf00a4
commit fbf07bf126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,7 +90,7 @@ from tests.auxil.pytest_classes import PytestExtBot, PytestMessage
from tests.auxil.slots import mro_slots
@pytest.fixture(scope="module")
@pytest.fixture
def message(bot):
message = PytestMessage(
message_id=TestMessageBase.id_,
@ -1193,16 +1193,20 @@ class TestMessageWithoutRequest(TestMessageBase):
# The leading - for group ids/ -100 for supergroup ids isn't supposed to be in the link
assert message.link == f"https://t.me/c/{3}/{message.message_id}"
def test_link_with_topics(self, message):
@pytest.mark.parametrize("type_", argvalues=[Chat.SUPERGROUP, Chat.CHANNEL])
def test_link_with_topics(self, message, type_):
message.chat.username = None
message.chat.id = -1003
message.chat.type = type_
message.is_topic_message = True
message.message_thread_id = 123
assert message.link == f"https://t.me/c/3/{message.message_id}?thread=123"
def test_link_with_reply(self, message):
@pytest.mark.parametrize("type_", argvalues=[Chat.SUPERGROUP, Chat.CHANNEL])
def test_link_with_reply(self, message, type_):
message.chat.username = None
message.chat.id = -1003
message.chat.type = type_
message.reply_to_message = Message(7, self.from_user, self.date, self.chat, text="Reply")
message.message_thread_id = 123
assert message.link == f"https://t.me/c/3/{message.message_id}?thread=123"