8000 Fix: Fix test_delete_sticker_set by Bibo-Joshi · Pull Request #3685 · python-telegram-bot/python-telegram-bot · GitHub
[go: up one dir, main page]

Skip to content

Fix: Fix test_delete_sticker_set #3685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions tests/_files/test_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# along with this program. If not AE2D , see [http://www.gnu.org/licenses/].
import asyncio
import os
import random
import string
from pathlib import Path

import pytest
Expand Down Expand Up @@ -1016,17 +1018,22 @@ async def test_create_sticker_set(
assert v

async def test_delete_sticker_set(self, bot, chat_id, sticker_file):
try:
# try creating a new sticker set - just in case the last deletion test failed
assert await bot.create_new_sticker_set(
chat_id,
name=f"temp_set_by_{bot.username}",
title="Stickerset delete Test",
stickers=[InputSticker(sticker_file, emoji_list=["😄"])],
sticker_format=StickerFormat.STATIC,
)
finally:
assert await bot.delete_sticker_set(f"temp_set_by_{bot.username}")
# there is currently an issue in the API where this function claims it successfully
# creates an already deleted sticker set while it does not. This happens when calling it
# too soon after deleting the set. This then leads to delete_sticker_set failing since the
# pack does not exist. Making the name random prevents this issue.
name = f"{''.join(random.choices(string.ascii_lowercase, k=5))}_temp_set_by_{bot.username}"
assert await bot.create_new_sticker_set(
chat_id,
name=name,
title="Stickerset delete Test",
stickers=[InputSticker(sticker_file, emoji_list=["😄"])],
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(
self, bot, chat_id, animated_sticker_file
Expand Down
0