From da7ca2807fc7800200b7ed7734ed42c36f1d41c3 Mon Sep 17 00:00:00 2001 From: t0rr Date: Wed, 8 Aug 2018 03:22:15 +0300 Subject: [PATCH] Test Message Reply Location --- tests/test_message.py | 25 +++++++++++++++++++++++++ tests/types/dataset.py | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/test_message.py b/tests/test_message.py index 48631195..14373159 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -405,3 +405,28 @@ class TestMessageReplyMediaGroup: assert len(result) == len(self.media) assert result[0] == msg + + +class TestMessageReplyLocation: + location = types.Location(**dataset.LOCATION) + + async def test_reply_location(self, message, bot, monkeypatch, event_loop): + """ Message.reply_location method test """ + msg = types.Message(**dataset.MESSAGE_WITH_LOCATION_AND_REPLY) + async with FakeTelegram(message_dict=dataset.MESSAGE_WITH_LOCATION_AND_REPLY, + loop=event_loop, bot=bot, monkeypatch=monkeypatch): + result = await message.reply_location(latitude=self.location.latitude, + longitude=self.location.longitude) + + assert result == msg + + async def test_reply_location_without_reply(self, message, bot, monkeypatch, event_loop): + """ Message.reply_location method test (without reply_to_message) """ + msg = types.Message(**dataset.MESSAGE_WITH_LOCATION) + + async with FakeTelegram(message_dict=dataset.MESSAGE_WITH_LOCATION, + loop=event_loop, bot=bot, monkeypatch=monkeypatch): + result = await message.reply_location(latitude=self.location.latitude, + longitude=self.location.longitude, reply=False) + + assert result == msg diff --git a/tests/types/dataset.py b/tests/types/dataset.py index f8114ce7..f7e472fe 100644 --- a/tests/types/dataset.py +++ b/tests/types/dataset.py @@ -343,6 +343,15 @@ MESSAGE_WITH_LOCATION = { "location": LOCATION } +MESSAGE_WITH_LOCATION_AND_REPLY = { + "message_id": 12345, + "from": USER, + "chat": CHAT, + "date": 1508755473, + "reply_to_message": MESSAGE, + "location": LOCATION +} + MESSAGE_WITH_MIGRATE_TO_CHAT_ID = { "message_id": 12345, "from": USER,