|
18 | 18 | # along with this program. If not, see [http://www.gnu.org/licenses/].
|
19 | 19 | import asyncio
|
20 | 20 | import os
|
| 21 | +import random |
| 22 | +import string |
21 | 23 | from pathlib import Path
|
22 | 24 |
|
23 | 25 | import pytest
|
@@ -1016,17 +1018,22 @@ async def test_create_sticker_set(
|
1016 | 1018 | assert v
|
1017 | 1019 |
|
1018 | 1020 | async def test_delete_sticker_set(self, bot, chat_id, sticker_file):
|
1019 |
| - try: |
1020 |
| - # try creating a new sticker set - just in case the last deletion test failed |
1021 |
| - assert await bot.create_new_sticker_set( |
1022 |
| - chat_id, |
1023 |
| - name=f"temp_set_by_{bot.username}", |
1024 |
| - title="Stickerset delete Test", |
1025 |
| - stickers=[InputSticker(sticker_file, emoji_list=["😄"])], |
1026 |
| - sticker_format=StickerFormat.STATIC, |
1027 |
| - ) |
1028 |
| - finally: |
1029 |
| - assert await bot.delete_sticker_set(f"temp_set_by_{bot.username}") |
| 1021 | + # there is currently an issue in the API where this function claims it successfully |
| 1022 | + # creates an already deleted sticker set while it does not. This happens when calling it |
| 1023 | + # too soon after deleting the set. This then leads to delete_sticker_set failing since the |
| 1024 | + # pack does not exist. Making the name random prevents this issue. |
| 1025 | + name = f"{''.join(random.choices(string.ascii_lowercase, k=5))}_temp_set_by_{bot.username}" |
| 1026 | + assert await bot.create_new_sticker_set( |
| 1027 | + chat_id, |
| 1028 | + name=name, |
| 1029 | + title="Stickerset delete Test", |
| 1030 | + stickers=[InputSticker(sticker_file, emoji_list=["😄"])], |
| 1031 | + sticker_format=StickerFormat.STATIC, |
| 1032 | + ) |
| 1033 | + # this prevents a second issue when calling delete too soon after creating the set leads |
| 1034 | + # to it failing as well |
| 1035 | + await asyncio.sleep(1) |
| 1036 | + assert await bot.delete_sticker_set(name) |
1030 | 1037 |
|
1031 | 1038 | async def test_set_custom_emoji_sticker_set_thumbnail(
|
1032 | 1039 | self, bot, chat_id, animated_sticker_file
|
|
0 commit comments