mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-10-24 01:46:22 +02:00
Stabilize test_delete_sticker_set
(#3685)
Co-authored-by: poolitzer <github@poolitzer.eu>
This commit is contained in:
parent
3f444dad8d
commit
83ab12c387
1 changed files with 18 additions and 11 deletions
|
@ -18,6 +18,8 @@
|
||||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
|
import string
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -1016,17 +1018,22 @@ class TestStickerSetWithRequest:
|
||||||
assert v
|
assert v
|
||||||
|
|
||||||
async def test_delete_sticker_set(self, bot, chat_id, sticker_file):
|
async def test_delete_sticker_set(self, bot, chat_id, sticker_file):
|
||||||
try:
|
# there is currently an issue in the API where this function claims it successfully
|
||||||
# try creating a new sticker set - just in case the last deletion test failed
|
# creates an already deleted sticker set while it does not. This happens when calling it
|
||||||
assert await bot.create_new_sticker_set(
|
# too soon after deleting the set. This then leads to delete_sticker_set failing since the
|
||||||
chat_id,
|
# pack does not exist. Making the name random prevents this issue.
|
||||||
name=f"temp_set_by_{bot.username}",
|
name = f"{''.join(random.choices(string.ascii_lowercase, k=5))}_temp_set_by_{bot.username}"
|
||||||
title="Stickerset delete Test",
|
assert await bot.create_new_sticker_set(
|
||||||
stickers=[InputSticker(sticker_file, emoji_list=["😄"])],
|
chat_id,
|
||||||
sticker_format=StickerFormat.STATIC,
|
name=name,
|
||||||
)
|
title="Stickerset delete Test",
|
||||||
finally:
|
stickers=[InputSticker(sticker_file, emoji_list=["😄"])],
|
||||||
assert await bot.delete_sticker_set(f"temp_set_by_{bot.username}")
|
sticker_format=StickerFormat.STATIC,
|
||||||
|
)
|
||||||
|
# this prevents a second issue when calling delete too soon after creating the set leads
|
||||||
|
# to it failing as well
|
||||||
|
await asyncio.sleep(1)
|
||||||
|
assert await bot.delete_sticker_set(name)
|
||||||
|
|
||||||
async def test_set_custom_emoji_sticker_set_thumbnail(
|
async def test_set_custom_emoji_sticker_set_thumbnail(
|
||||||
self, bot, chat_id, animated_sticker_file
|
self, bot, chat_id, animated_sticker_file
|
||||||
|
|
Loading…
Reference in a new issue