Add new conftest file in _files/

This commit is contained in:
Harshil 2024-05-21 16:21:28 -04:00
parent 2ca1ce2762
commit cb5425652d
No known key found for this signature in database
GPG key ID: 4AC061E441A1F727
15 changed files with 169 additions and 170 deletions

View file

@ -66,7 +66,7 @@ markers = [
"no_req",
"req",
]
asyncio_mode = "auto"
# asyncio_mode = "auto"
log_format = "%(funcName)s - Line %(lineno)d - %(message)s"
# log_level = "DEBUG" # uncomment to see DEBUG logs

106
tests/_files/conftest.py Normal file
View file

@ -0,0 +1,106 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2024
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""Module to provide fixtures most of which are used in test_inputmedia.py."""
import pytest
from tests.auxil.files import data_file
from tests.auxil.networking import expect_bad_request
@pytest.fixture()
def animation_file():
with data_file("game.gif").open("rb") as f:
yield f
@pytest.fixture(scope="session")
async def animation(bot, chat_id, aiolib):
with data_file("game.gif").open("rb") as f, data_file("thumb.jpg").open("rb") as thumb:
return (
await bot.send_animation(chat_id, animation=f, read_timeout=50, thumbnail=thumb)
).animation
@pytest.fixture()
def audio_file():
with data_file("telegram.mp3").open("rb") as f:
yield f
@pytest.fixture(scope="session")
async def audio(bot, chat_id, aiolib):
with data_file("telegram.mp3").open("rb") as f, data_file("thumb.jpg").open("rb") as thumb:
return (await bot.send_audio(chat_id, audio=f, read_timeout=50, thumbnail=thumb)).audio
@pytest.fixture()
def document_file():
with data_file("telegram.png").open("rb") as f:
yield f
@pytest.fixture(scope="session")
async def document(bot, chat_id, aiolib):
with data_file("telegram.png").open("rb") as f:
return (await bot.send_document(chat_id, document=f, read_timeout=50)).document
@pytest.fixture()
def photo_file():
with data_file("telegram.jpg").open("rb") as f:
yield f
@pytest.fixture(scope="session")
async def photolist(bot, chat_id, aiolib):
async def func():
with data_file("telegram.jpg").open("rb") as f:
return (await bot.send_photo(chat_id, photo=f, read_timeout=50)).photo
return await expect_bad_request(
func, "Type of file mismatch", "Telegram did not accept the file."
)
@pytest.fixture(scope="session")
def thumb(photolist):
return photolist[0]
@pytest.fixture(scope="session")
def photo(photolist):
return photolist[-1]
@pytest.fixture()
def video_file():
with data_file("telegram.mp4").open("rb") as f:
yield f
@pytest.fixture(scope="session")
async def video(bot, chat_id, aiolib):
with data_file("telegram.mp4").open("rb") as f:
return (await bot.send_video(chat_id, video=f, read_timeout=50)).video
@pytest.fixture()
def video_sticker_file():
with data_file("telegram_video_sticker.webm").open("rb") as f:
yield f

View file

@ -37,20 +37,6 @@ from tests.auxil.files import data_file
from tests.auxil.slots import mro_slots
@pytest.fixture()
def animation_file():
with data_file("game.gif").open("rb") as f:
yield f
@pytest.fixture(scope="module")
async def animation(bot, chat_id):
with data_file("game.gif").open("rb") as f, data_file("thumb.jpg").open("rb") as thumb:
return (
await bot.send_animation(chat_id, animation=f, read_timeout=50, thumbnail=thumb)
).animation
class TestAnimationBase:
animation_file_id = "CgADAQADngIAAuyVeEez0xRovKi9VAI"
animation_file_unique_id = "adc3145fd2e84d95b64d68eaa22aa33e"

View file

@ -37,18 +37,6 @@ from tests.auxil.files import data_file
from tests.auxil.slots import mro_slots
@pytest.fixture()
def audio_file():
with data_file("telegram.mp3").open("rb") as f:
yield f
@pytest.fixture(scope="module")
async def audio(bot, chat_id):
with data_file("telegram.mp3").open("rb") as f, data_file("thumb.jpg").open("rb") as thumb:
return (await bot.send_audio(chat_id, audio=f, read_timeout=50, thumbnail=thumb)).audio
class TestAudioBase:
caption = "Test *audio*"
performer = "Leandro Toledo"

View file

@ -37,18 +37,6 @@ from tests.auxil.files import data_file
from tests.auxil.slots import mro_slots
@pytest.fixture()
def document_file():
with data_file("telegram.png").open("rb") as f:
yield f
@pytest.fixture(scope="module")
async def document(bot, chat_id):
with data_file("telegram.png").open("rb") as f:
return (await bot.send_document(chat_id, document=f, read_timeout=50)).document
class TestDocumentBase:
caption = "DocumentTest - *Caption*"
document_file_url = "https://python-telegram-bot.org/static/testfiles/telegram.gif"

View file

@ -36,32 +36,14 @@ from telegram import (
ReplyParameters,
)
from telegram.constants import InputMediaType, ParseMode
# noinspection PyUnresolvedReferences
from telegram.error import BadRequest
from telegram.request import RequestData
from tests._files.test_animation import animation, animation_file # noqa: F401
from tests.auxil.files import data_file
from tests.auxil.networking import expect_bad_request
from tests.auxil.slots import mro_slots
# noinspection PyUnresolvedReferences
from tests.test_forum import emoji_id, real_topic # noqa: F401
from ..auxil.build_messages import make_message
# noinspection PyUnresolvedReferences
from .test_audio import audio, audio_file # noqa: F401
# noinspection PyUnresolvedReferences
from .test_document import document, document_file # noqa: F401
# noinspection PyUnresolvedReferences
from .test_photo import photo, photo_file, photolist, thumb # noqa: F401
# noinspection PyUnresolvedReferences
from .test_video import video, video_file # noqa: F401
@pytest.fixture(scope="module")
def input_media_video(class_thumb_file):
@ -183,7 +165,7 @@ class TestInputMediaVideoWithoutRequest(TestInputMediaVideoBase):
assert input_media_video_dict["supports_streaming"] == input_media_video.supports_streaming
assert input_media_video_dict["has_spoiler"] == input_media_video.has_spoiler
def test_with_video(self, video): # noqa: F811
def test_with_video(self, video):
# fixture found in test_video
input_media_video = InputMediaVideo(video, caption="test 3")
assert input_media_video.type == self.type_
@ -193,7 +175,7 @@ class TestInputMediaVideoWithoutRequest(TestInputMediaVideoBase):
assert input_media_video.duration == video.duration
assert input_media_video.caption == "test 3"
def test_with_video_file(self, video_file): # noqa: F811
def test_with_video_file(self, video_file):
# fixture found in test_video
input_media_video = InputMediaVideo(video_file, caption="test 3")
assert input_media_video.type == self.type_
@ -267,14 +249,14 @@ class TestInputMediaPhotoWithoutRequest(TestInputMediaPhotoBase):
]
assert input_media_photo_dict["has_spoiler"] == input_media_photo.has_spoiler
def test_with_photo(self, photo): # noqa: F811
def test_with_photo(self, photo):
# fixture found in test_photo
input_media_photo = InputMediaPhoto(photo, caption="test 2")
assert input_media_photo.type == self.type_
assert input_media_photo.media == photo.file_id
assert input_media_photo.caption == "test 2"
def test_with_photo_file(self, photo_file): # noqa: F811
def test_with_photo_file(self, photo_file):
# fixture found in test_photo
input_media_photo = InputMediaPhoto(photo_file, caption="test 2")
assert input_media_photo.type == self.type_
@ -332,14 +314,14 @@ class TestInputMediaAnimationWithoutRequest(TestInputMediaAnimationBase):
assert input_media_animation_dict["duration"] == input_media_animation.duration
assert input_media_animation_dict["has_spoiler"] == input_media_animation.has_spoiler
def test_with_animation(self, animation): # noqa: F811
def test_with_animation(self, animation):
# fixture found in test_animation
input_media_animation = InputMediaAnimation(animation, caption="test 2")
assert input_media_animation.type == self.type_
assert input_media_animation.media == animation.file_id
assert input_media_animation.caption == "test 2"
def test_with_animation_file(self, animation_file): # noqa: F811
def test_with_animation_file(self, animation_file):
# fixture found in test_animation
input_media_animation = InputMediaAnimation(animation_file, caption="test 2")
assert input_media_animation.type == self.type_
@ -400,7 +382,7 @@ class TestInputMediaAudioWithoutRequest(TestInputMediaAudioBase):
ce.to_dict() for ce in input_media_audio.caption_entities
]
def test_with_audio(self, audio): # noqa: F811
def test_with_audio(self, audio):
# fixture found in test_audio
input_media_audio = InputMediaAudio(audio, caption="test 3")
assert input_media_audio.type == self.type_
@ -410,7 +392,7 @@ class TestInputMediaAudioWithoutRequest(TestInputMediaAudioBase):
assert input_media_audio.title == audio.title
assert input_media_audio.caption == "test 3"
def test_with_audio_file(self, audio_file): # noqa: F811
def test_with_audio_file(self, audio_file):
# fixture found in test_audio
input_media_audio = InputMediaAudio(audio_file, caption="test 3")
assert input_media_audio.type == self.type_
@ -471,14 +453,14 @@ class TestInputMediaDocumentWithoutRequest(TestInputMediaDocumentBase):
== input_media_document.disable_content_type_detection
)
def test_with_document(self, document): # noqa: F811
def test_with_document(self, document):
# fixture found in test_document
input_media_document = InputMediaDocument(document, caption="test 3")
assert input_media_document.type == self.type_
assert input_media_document.media == document.file_id
assert input_media_document.caption == "test 3"
def test_with_document_file(self, document_file): # noqa: F811
def test_with_document_file(self, document_file):
# fixture found in test_document
input_media_document = InputMediaDocument(document_file, caption="test 3")
assert input_media_document.type == self.type_
@ -494,7 +476,7 @@ class TestInputMediaDocumentWithoutRequest(TestInputMediaDocumentBase):
@pytest.fixture(scope="module")
def media_group(photo, thumb): # noqa: F811
def media_group(photo, thumb):
return [
InputMediaPhoto(photo, caption="*photo* 1", parse_mode="Markdown"),
InputMediaPhoto(thumb, caption="<b>photo</b> 2", parse_mode="HTML"),
@ -505,12 +487,12 @@ def media_group(photo, thumb): # noqa: F811
@pytest.fixture(scope="module")
def media_group_no_caption_args(photo, thumb): # noqa: F811
def media_group_no_caption_args(photo, thumb):
return [InputMediaPhoto(photo), InputMediaPhoto(thumb), InputMediaPhoto(photo)]
@pytest.fixture(scope="module")
def media_group_no_caption_only_caption_entities(photo, thumb): # noqa: F811
def media_group_no_caption_only_caption_entities(photo, thumb):
return [
InputMediaPhoto(photo, caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 5)]),
InputMediaPhoto(photo, caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 5)]),
@ -518,7 +500,7 @@ def media_group_no_caption_only_caption_entities(photo, thumb): # noqa: F811
@pytest.fixture(scope="module")
def media_group_no_caption_only_parse_mode(photo, thumb): # noqa: F811
def media_group_no_caption_only_parse_mode(photo, thumb):
return [
InputMediaPhoto(photo, parse_mode="Markdown"),
InputMediaPhoto(thumb, parse_mode="HTML"),
@ -549,10 +531,10 @@ class TestSendMediaGroupWithoutRequest:
self,
bot,
chat_id,
photo_file, # noqa: F811
animation_file, # noqa: F811
audio_file, # noqa: F811
video_file, # noqa: F811
photo_file,
animation_file,
audio_file,
video_file,
monkeypatch,
):
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
@ -576,7 +558,7 @@ class TestSendMediaGroupWithoutRequest:
await bot.send_media_group(chat_id, media)
async def test_send_media_group_with_thumbs(
self, bot, chat_id, video_file, photo_file, monkeypatch # noqa: F811
self, bot, chat_id, video_file, photo_file, monkeypatch
):
async def make_assertion(method, url, request_data: RequestData, *args, **kwargs):
nonlocal input_video
@ -594,7 +576,7 @@ class TestSendMediaGroupWithoutRequest:
await bot.send_media_group(chat_id, [input_video, input_video])
async def test_edit_message_media_with_thumb(
self, bot, chat_id, video_file, photo_file, monkeypatch # noqa: F811
self, bot, chat_id, video_file, photo_file, monkeypatch
):
async def make_assertion(
method: str, url: str, request_data: Optional[RequestData] = None, *args, **kwargs
@ -663,9 +645,7 @@ class TestSendMediaGroupWithRequest:
mes.caption_entities == (MessageEntity(MessageEntity.BOLD, 0, 5),) for mes in messages
)
async def test_send_media_group_new_files(
self, bot, chat_id, video_file, photo_file # noqa: F811
):
async def test_send_media_group_new_files(self, bot, chat_id, video_file, photo_file):
async def func():
return await bot.send_media_group(
chat_id,
@ -701,7 +681,7 @@ class TestSendMediaGroupWithRequest:
assert all(mes.media_group_id == messages[0].media_group_id for mes in messages)
async def test_send_media_group_with_message_thread_id(
self, bot, real_topic, forum_group_id, media_group # noqa: F811
self, bot, real_topic, forum_group_id, media_group
):
messages = await bot.send_media_group(
forum_group_id,
@ -800,9 +780,7 @@ class TestSendMediaGroupWithRequest:
)
assert all(mes.has_protected_content for mes in messages)
async def test_send_media_group_with_spoiler(
self, bot, chat_id, photo_file, video_file # noqa: F811
):
async def test_send_media_group_with_spoiler(self, bot, chat_id, photo_file, video_file):
# Media groups can't contain Animations, so that is tested in test_animation.py
media = [
InputMediaPhoto(photo_file, has_spoiler=True),
@ -945,11 +923,11 @@ class TestSendMediaGroupWithRequest:
chat_id,
default_bot,
media_type,
animation, # noqa: F811
document, # noqa: F811
audio, # noqa: F811
photo, # noqa: F811
video, # noqa: F811
animation,
document,
audio,
photo,
video,
):
html_caption = "<b>bold</b> <i>italic</i> <code>code</code>"
markdown_caption = "*bold* _italic_ `code`"

View file

@ -21,7 +21,6 @@ import pytest
from telegram import InputSticker, MaskPosition
from telegram._files.inputfile import InputFile
from tests._files.test_sticker import video_sticker_file # noqa: F401
from tests.auxil.files import data_file
from tests.auxil.slots import mro_slots
@ -77,7 +76,7 @@ class TestInputStickerWithoutRequest(TestInputStickerBase):
assert input_sticker_dict["keywords"] == list(input_sticker.keywords)
assert input_sticker_dict["format"] == input_sticker.format
def test_with_sticker_input_types(self, video_sticker_file): # noqa: F811
def test_with_sticker_input_types(self, video_sticker_file):
sticker = InputSticker(sticker=video_sticker_file, emoji_list=["👍"], format="video")
assert isinstance(sticker.sticker, InputFile)
sticker = InputSticker(data_file("telegram_video_sticker.webm"), ["👍"], "video")

View file

@ -34,37 +34,9 @@ from tests.auxil.bot_method_checks import (
)
from tests.auxil.build_messages import make_message
from tests.auxil.files import data_file
from tests.auxil.networking import expect_bad_request
from tests.auxil.slots import mro_slots
@pytest.fixture()
def photo_file():
with data_file("telegram.jpg").open("rb") as f:
yield f
@pytest.fixture(scope="module")
async def photolist(bot, chat_id):
async def func():
with data_file("telegram.jpg").open("rb") as f:
return (await bot.send_photo(chat_id, photo=f, read_timeout=50)).photo
return await expect_bad_request(
func, "Type of file mismatch", "Telegram did not accept the file."
)
@pytest.fixture(scope="module")
def thumb(photolist):
return photolist[0]
@pytest.fixture(scope="module")
def photo(photolist):
return photolist[-1]
class TestPhotoBase:
width = 800
height = 800

View file

@ -77,12 +77,6 @@ async def animated_sticker(bot, chat_id):
return (await bot.send_sticker(chat_id, sticker=f, read_timeout=50)).sticker
@pytest.fixture()
def video_sticker_file():
with data_file("telegram_video_sticker.webm").open("rb") as f:
yield f
@pytest.fixture(scope="module")
def video_sticker(bot, chat_id):
with data_file("telegram_video_sticker.webm").open("rb") as f:

View file

@ -37,18 +37,6 @@ from tests.auxil.files import data_file
from tests.auxil.slots import mro_slots
@pytest.fixture()
def video_file():
with data_file("telegram.mp4").open("rb") as f:
yield f
@pytest.fixture(scope="module")
async def video(bot, chat_id):
with data_file("telegram.mp4").open("rb") as f:
return (await bot.send_video(chat_id, video=f, read_timeout=50)).video
class TestVideoBase:
width = 360
height = 640

View file

@ -244,7 +244,7 @@ class TestVideoNoteWithRequest(TestVideoNoteBase):
assert message.video_note.thumbnail.height == self.thumb_height
assert message.has_protected_content
async def test_get_and_download(self, bot, video_note, chat_id, tmp_file):
async def test_get_and_download(self, bot, video_note, tmp_file):
new_file = await bot.get_file(video_note.file_id)
assert new_file.file_size == self.file_size

View file

@ -20,3 +20,7 @@
# THIS KEY IS OBVIOUSLY COMPROMISED
# DO NOT USE IN PRODUCTION!
PRIVATE_KEY = b"-----BEGIN RSA PRIVATE KEY-----\r\nMIIEowIBAAKCAQEA0AvEbNaOnfIL3GjB8VI4M5IaWe+GcK8eSPHkLkXREIsaddum\r\nwPBm/+w8lFYdnY+O06OEJrsaDtwGdU//8cbGJ/H/9cJH3dh0tNbfszP7nTrQD+88\r\nydlcYHzClaG8G+oTe9uEZSVdDXj5IUqR0y6rDXXb9tC9l+oSz+ShYg6+C4grAb3E\r\nSTv5khZ9Zsi/JEPWStqNdpoNuRh7qEYc3t4B/a5BH7bsQENyJSc8AWrfv+drPAEe\r\njQ8xm1ygzWvJp8yZPwOIYuL+obtANcoVT2G2150Wy6qLC0bD88Bm40GqLbSazueC\r\nRHZRug0B9rMUKvKc4FhG4AlNzBCaKgIcCWEqKwIDAQABAoIBACcIjin9d3Sa3S7V\r\nWM32JyVF3DvTfN3XfU8iUzV7U+ZOswA53eeFM04A/Ly4C4ZsUNfUbg72O8Vd8rg/\r\n8j1ilfsYpHVvphwxaHQlfIMa1bKCPlc/A6C7b2GLBtccKTbzjARJA2YWxIaqk9Nz\r\nMjj1IJK98i80qt29xRnMQ5sqOO3gn2SxTErvNchtBiwOH8NirqERXig8VCY6fr3n\r\nz7ZImPU3G/4qpD0+9ULrt9x/VkjqVvNdK1l7CyAuve3D7ha3jPMfVHFtVH5gqbyp\r\nKotyIHAyD+Ex3FQ1JV+H7DkP0cPctQiss7OiO9Zd9C1G2OrfQz9el7ewAPqOmZtC\r\nKjB3hUECgYEA/4MfKa1cvaCqzd3yUprp1JhvssVkhM1HyucIxB5xmBcVLX2/Kdhn\r\nhiDApZXARK0O9IRpFF6QVeMEX7TzFwB6dfkyIePsGxputA5SPbtBlHOvjZa8omMl\r\nEYfNa8x/mJkvSEpzvkWPascuHJWv1cEypqphu/70DxubWB5UKo/8o6cCgYEA0HFy\r\ncgwPMB//nltHGrmaQZPFT7/Qgl9ErZT3G9S8teWY4o4CXnkdU75tBoKAaJnpSfX3\r\nq8VuRerF45AFhqCKhlG4l51oW7TUH50qE3GM+4ivaH5YZB3biwQ9Wqw+QyNLAh/Q\r\nnS4/Wwb8qC9QuyEgcCju5lsCaPEXZiZqtPVxZd0CgYEAshBG31yZjO0zG1TZUwfy\r\nfN3euc8mRgZpSdXIHiS5NSyg7Zr8ZcUSID8jAkJiQ3n3OiAsuq1MGQ6kNa582kLT\r\nFPQdI9Ea8ahyDbkNR0gAY9xbM2kg/Gnro1PorH9PTKE0ekSodKk1UUyNrg4DBAwn\r\nqE6E3ebHXt/2WmqIbUD653ECgYBQCC8EAQNX3AFegPd1GGxU33Lz4tchJ4kMCNU0\r\nN2NZh9VCr3nTYjdTbxsXU8YP44CCKFG2/zAO4kymyiaFAWEOn5P7irGF/JExrjt4\r\nibGy5lFLEq/HiPtBjhgsl1O0nXlwUFzd7OLghXc+8CPUJaz5w42unqT3PBJa40c3\r\nQcIPdQKBgBnSb7BcDAAQ/Qx9juo/RKpvhyeqlnp0GzPSQjvtWi9dQRIu9Pe7luHc\r\nm1Img1EO1OyE3dis/rLaDsAa2AKu1Yx6h85EmNjavBqP9wqmFa0NIQQH8fvzKY3/\r\nP8IHY6009aoamLqYaexvrkHVq7fFKiI6k8myMJ6qblVNFv14+KXU\r\n-----END RSA PRIVATE KEY-----" # noqa: E501
TEST_MSG_TEXT = "Topics are forever"
TEST_TOPIC_ICON_COLOR = 0x6FB9F0
TEST_TOPIC_NAME = "Sad bot true: real stories"

View file

@ -40,7 +40,7 @@ from telegram.ext import ApplicationBuilder, Defaults, Updater
from telegram.ext.filters import MessageFilter, UpdateFilter
from tests.auxil.build_messages import DATE
from tests.auxil.ci_bots import BOT_INFO_PROVIDER
from tests.auxil.constants import PRIVATE_KEY
from tests.auxil.constants import PRIVATE_KEY, TEST_TOPIC_ICON_COLOR, TEST_TOPIC_NAME
from tests.auxil.envvars import RUN_TEST_OFFICIAL, TEST_WITH_OPT_DEPS
from tests.auxil.files import data_file
from tests.auxil.networking import NonchalantHttpxRequest
@ -239,6 +239,30 @@ def class_thumb_file():
yield f
@pytest.fixture(scope="session")
async def emoji_id(bot):
emoji_sticker_list = await bot.get_forum_topic_icon_stickers()
first_sticker = emoji_sticker_list[0]
return first_sticker.custom_emoji_id
@pytest.fixture()
async def real_topic(bot, emoji_id, forum_group_id):
result = await bot.create_forum_topic(
chat_id=forum_group_id,
name=TEST_TOPIC_NAME,
icon_color=TEST_TOPIC_ICON_COLOR,
icon_custom_emoji_id=emoji_id,
)
yield result
result = await bot.delete_forum_topic(
chat_id=forum_group_id, message_thread_id=result.message_thread_id
)
assert result is True, "Topic was not deleted"
@pytest.fixture(
scope="class",
params=[{"class": MessageFilter}, {"class": UpdateFilter}],

View file

@ -99,11 +99,10 @@ from tests.auxil.networking import expect_bad_request
from tests.auxil.pytest_classes import PytestBot, PytestExtBot, make_bot
from tests.auxil.slots import mro_slots
from ._files.test_photo import photo_file
from .auxil.build_messages import make_message
@pytest.fixture()
@pytest.fixture(scope="module")
async def message(bot, chat_id): # mostly used in tests for edit_message
out = await bot.send_message(
chat_id, "Text", disable_web_page_preview=True, disable_notification=True
@ -1090,7 +1089,7 @@ class TestBotWithoutRequest:
)
# Test with send media group
media = InputMediaPhoto(photo_file)
media = InputMediaPhoto("")
with pytest.raises(ValueError, match="`reply_to_message_id` and"):
await bot.send_media_group(
chat_id, media, reply_to_message_id=1, reply_parameters=True

View file

@ -32,19 +32,9 @@ from telegram import (
Sticker,
)
from telegram.error import BadRequest
from tests.auxil.constants import TEST_MSG_TEXT, TEST_TOPIC_ICON_COLOR, TEST_TOPIC_NAME
from tests.auxil.slots import mro_slots
TEST_MSG_TEXT = "Topics are forever"
TEST_TOPIC_ICON_COLOR = 0x6FB9F0
TEST_TOPIC_NAME = "Sad bot true: real stories"
@pytest.fixture(scope="module")
async def emoji_id(bot):
emoji_sticker_list = await bot.get_forum_topic_icon_stickers()
first_sticker = emoji_sticker_list[0]
return first_sticker.custom_emoji_id
@pytest.fixture(scope="module")
async def forum_topic_object(forum_group_id, emoji_id):
@ -56,23 +46,6 @@ async def forum_topic_object(forum_group_id, emoji_id):
)
@pytest.fixture()
async def real_topic(bot, emoji_id, forum_group_id):
result = await bot.create_forum_topic(
chat_id=forum_group_id,
name=TEST_TOPIC_NAME,
icon_color=TEST_TOPIC_ICON_COLOR,
icon_custom_emoji_id=emoji_id,
)
yield result
result = await bot.delete_forum_topic(
chat_id=forum_group_id, message_thread_id=result.message_thread_id
)
assert result is True, "Topic was not deleted"
class TestForumTopicWithoutRequest:
def test_slot_behaviour(self, forum_topic_object):
inst = forum_topic_object