From 0c3ce1cf00033706a355720608ea66e45188a0ad Mon Sep 17 00:00:00 2001 From: Oleg Abramov Date: Wed, 4 Apr 2018 12:42:01 +0300 Subject: [PATCH] Added tests sendPhoto --- tests/test_bot.py | 18 +++++++++++++++--- tests/types/dataset.py | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_bot.py b/tests/test_bot.py index c297eacb..8937f4fb 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -49,7 +49,7 @@ async def test_get_me(bot: Bot, event_loop): user = types.User(**USER) async with FakeTelegram(message_dict=USER, loop=event_loop): - result = await bot.get_me() + result = await bot.me assert result == user @@ -69,14 +69,26 @@ async def test_forward_message(bot: Bot, event_loop): """ forwardMessage method test """ from .types.dataset import FORWARDED_MESSAGE msg = types.Message(**FORWARDED_MESSAGE) - from_chat = -1234567890 async with FakeTelegram(message_dict=FORWARDED_MESSAGE, loop=event_loop): - result = await bot.forward_message(chat_id=msg.chat.id, from_chat_id=from_chat, + result = await bot.forward_message(chat_id=msg.chat.id, from_chat_id=msg.forward_from_chat.id, message_id=msg.forward_from_message_id) assert result == msg +@pytest.mark.asyncio +async def test_photo_message(bot: Bot, event_loop): + """ sendPhoto method test """ + from .types.dataset import MESSAGE_WITH_PHOTO, PHOTO + msg = types.Message(**MESSAGE_WITH_PHOTO) + photo = types.PhotoSize(**PHOTO) + + async with FakeTelegram(message_dict=MESSAGE_WITH_PHOTO, loop=event_loop): + result = await bot.send_photo(msg.chat.id, photo=photo.file_id, caption=msg.caption, + parse_mode=types.ParseMode.HTML, disable_notification=False) + assert result == msg + + @pytest.mark.asyncio async def test_send_audio(bot: Bot, event_loop): """ sendAudio method test """ diff --git a/tests/types/dataset.py b/tests/types/dataset.py index 259f7980..8bc91037 100644 --- a/tests/types/dataset.py +++ b/tests/types/dataset.py @@ -272,7 +272,7 @@ MESSAGE_WITH_PHOTO = { "from": USER, "chat": CHAT, "date": 1508825154, - "photo": [PHOTO, PHOTO, PHOTO, PHOTO], # 4 sizes of one photo + "photo": [PHOTO, PHOTO, PHOTO, PHOTO], "caption": "photo description" }