Added tests sendPhoto

This commit is contained in:
Oleg Abramov 2018-04-04 12:42:01 +03:00
parent 24a7788393
commit 0c3ce1cf00
2 changed files with 16 additions and 4 deletions

View file

@ -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 """

View file

@ -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"
}