From c5ec1f729e73e334f205cbc17aea6e3d922853b1 Mon Sep 17 00:00:00 2001 From: Eldinnie Date: Wed, 23 Aug 2017 22:47:03 +0200 Subject: [PATCH 1/3] Fix sticker tests Added flaky, timeout and xfails to the stickerset bot method tests. --- tests/test_sticker.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_sticker.py b/tests/test_sticker.py index 06acd7a3933..213ff80f1a2 100644 --- a/tests/test_sticker.py +++ b/tests/test_sticker.py @@ -249,12 +249,17 @@ 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) + @pytest.mark.xfail(raises=BadRequest) 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, '😄') + @flaky(3,1) + @pytest.mark.timeout(10) @pytest.mark.xfail(raises=BadRequest, reason='STICKERSET_NOT_MODIFIED errors on deletion') def test_bot_methods_2(self, bot, sticker_set): updated_sticker_set = bot.get_sticker_set(sticker_set.name) From 25dca8c1df8d394928bd665b3466ce8aa412fc5a Mon Sep 17 00:00:00 2001 From: Eldin Date: Wed, 23 Aug 2017 23:33:52 +0200 Subject: [PATCH 2/3] Make sure the first stickersettest worked before modifying in test 2 --- tests/test_sticker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_sticker.py b/tests/test_sticker.py index 213ff80f1a2..6d8b5e9e66e 100644 --- a/tests/test_sticker.py +++ b/tests/test_sticker.py @@ -263,7 +263,7 @@ def test_bot_methods_1(self, bot, sticker_set): @pytest.mark.xfail(raises=BadRequest, reason='STICKERSET_NOT_MODIFIED errors on deletion') 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 + assert len(updated_sticker_set.stickers) == 6 # 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) assert bot.delete_sticker_from_set(file_id) From 2d4b291dd874bd595779fc20b172efa64866fbd3 Mon Sep 17 00:00:00 2001 From: Eldin Date: Thu, 24 Aug 2017 00:31:10 +0200 Subject: [PATCH 3/3] some mor changes to make the deletion more stable --- tests/test_sticker.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_sticker.py b/tests/test_sticker.py index 6d8b5e9e66e..cc394a88f1e 100644 --- a/tests/test_sticker.py +++ b/tests/test_sticker.py @@ -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 @@ -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): @@ -251,7 +255,6 @@ def test_sticker_set_to_dict(self, sticker_set): @flaky(3,1) @pytest.mark.timeout(10) - @pytest.mark.xfail(raises=BadRequest) 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) @@ -260,12 +263,15 @@ def test_bot_methods_1(self, bot, sticker_set): @flaky(3,1) @pytest.mark.timeout(10) - @pytest.mark.xfail(raises=BadRequest, reason='STICKERSET_NOT_MODIFIED errors on deletion') 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) == 6 # 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): 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