Skip to content

Fix sticker tests #807

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 3 commits into from
Sep 1, 2017
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
25 changes: 18 additions & 7 deletions tests/test_sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import os
from time import sleep

import pytest
from flaky import flaky
Expand Down Expand Up @@ -214,9 +215,12 @@ def test_equality(self, sticker):
assert hash(a) != hash(e)


@pytest.fixture(scope='class')
@pytest.fixture(scope='function')
def sticker_set(bot):
return bot.get_sticker_set('test_by_{0}'.format(bot.username))
ss = bot.get_sticker_set('test_by_{0}'.format(bot.username))
if len(ss.stickers) > 100:
raise Exception('stickerset is growing too large.')
return ss


class TestStickerSet(object):
Expand Down Expand Up @@ -249,18 +253,25 @@ def test_sticker_set_to_dict(self, sticker_set):
assert sticker_set_dict['contains_masks'] == sticker_set.contains_masks
assert sticker_set_dict['stickers'][0] == sticker_set.stickers[0].to_dict()

@flaky(3,1)
@pytest.mark.timeout(10)
def test_bot_methods_1(self, bot, sticker_set):
with open('tests/data/telegram_sticker.png', 'rb') as f:
file = bot.upload_sticker_file(95205500, f)
assert file
assert bot.add_sticker_to_set(95205500, sticker_set.name, file.file_id, '😄')

@pytest.mark.xfail(raises=BadRequest, reason='STICKERSET_NOT_MODIFIED errors on deletion')
@flaky(3,1)
@pytest.mark.timeout(10)
def test_bot_methods_2(self, bot, sticker_set):
updated_sticker_set = bot.get_sticker_set(sticker_set.name)
assert len(updated_sticker_set.stickers) > 1 # Otherwise test_bot_methods_1 failed
file_id = updated_sticker_set.stickers[-1].file_id
assert bot.set_sticker_position_in_set(file_id, len(updated_sticker_set.stickers) - 1)
file_id = sticker_set.stickers[0].file_id
assert bot.set_sticker_position_in_set(file_id, 1)

@flaky(10, 1)
@pytest.mark.timeout(10)
def test_bot_methods_3(self, bot, sticker_set):
sleep(1)
file_id = sticker_set.stickers[-1].file_id
assert bot.delete_sticker_from_set(file_id)

def test_equality(self):
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy