From 486978abe46b449be7b5fc01ce30a75888db1ae7 Mon Sep 17 00:00:00 2001 From: Oleg Abramov Date: Wed, 4 Apr 2018 16:55:14 +0300 Subject: [PATCH] Add sendVenue test --- tests/test_bot.py | 19 +++++++++++++++++-- tests/types/dataset.py | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/test_bot.py b/tests/test_bot.py index 13cb43ab..c8fb6472 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -186,7 +186,7 @@ async def test_send_location(bot: Bot, event_loop): @pytest.mark.asyncio async def test_edit_message_live_location(bot: Bot, event_loop): - """ editMessageLiveLocation method test""" + """ editMessageLiveLocation method test """ from .types.dataset import MESSAGE_WITH_LOCATION, LOCATION msg = types.Message(**MESSAGE_WITH_LOCATION) location = types.Location(**LOCATION) @@ -206,7 +206,7 @@ async def test_edit_message_live_location(bot: Bot, event_loop): @pytest.mark.asyncio async def test_stop_message_live_location(bot: Bot, event_loop): - """ editMessageLiveLocation method test""" + """ stopMessageLiveLocation method test """ from .types.dataset import MESSAGE_WITH_LOCATION msg = types.Message(**MESSAGE_WITH_LOCATION) @@ -219,3 +219,18 @@ async def test_stop_message_live_location(bot: Bot, event_loop): async with FakeTelegram(message_dict=True, loop=event_loop): result = await bot.stop_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id) assert isinstance(result, bool) and result is True + + +@pytest.mark.asyncio +async def test_send_venue(bot: Bot, event_loop): + """ sendVenue method test """ + from .types.dataset import MESSAGE_WITH_VENUE, VENUE, LOCATION + msg = types.Message(**MESSAGE_WITH_VENUE) + location = types.Location(**LOCATION) + venue = types.Venue(**VENUE) + + async with FakeTelegram(message_dict=MESSAGE_WITH_VENUE, loop=event_loop): + result = await bot.send_venue(msg.chat.id, latitude=location.latitude, longitude=location.longitude, + title=venue.title, address=venue.address, foursquare_id=venue.foursquare_id, + disable_notification=False) + assert result == msg diff --git a/tests/types/dataset.py b/tests/types/dataset.py index 270dc4cb..d2a5eecd 100644 --- a/tests/types/dataset.py +++ b/tests/types/dataset.py @@ -106,8 +106,15 @@ INVOICE = { } LOCATION = { - "latitude": 55.693416, - "longitude": 37.624605 + "latitude": 50.693416, + "longitude": 30.624605 +} + +VENUE = { + "location": LOCATION, + "title": "Venue Name", + "address": "Venue Address", + "foursquare_id": "4e6f2cec483bad563d150f98" } SHIPPING_ADDRESS = { @@ -315,7 +322,14 @@ MESSAGE_WITH_SUCCESSFUL_PAYMENT = { MESSAGE_WITH_SUPERGROUP_CHAT_CREATED = {} -MESSAGE_WITH_VENUE = {} +MESSAGE_WITH_VENUE = { + "message_id": 56004, + "from": USER, + "chat": CHAT, + "date": 1522849819, + "location": LOCATION, + "venue": VENUE +} MESSAGE_WITH_VIDEO = { "message_id": 12345,