Example #1
0
def test_chat_methods():
    bot = MockBot()
    chat_id = 42
    chat = TgChat(bot, chat_id)

    chat.send_text("hello")
    assert "sendMessage" in bot.calls
    assert bot.calls["sendMessage"]["text"] == "hello"

    # Just test a single wrapper, the rest are same
    chat.send_photo()
    assert "sendPhoto" in bot.calls
    assert isinstance(bot.calls["sendPhoto"]["chat_id"], str)
Example #2
0
def test_chat_reply():
    bot = MockBot()
    msg = text_msg("Reply!")
    chat = TgChat.from_message(bot, msg)

    chat.reply("Hi " + repr(chat.sender))
    assert "sendMessage" in bot.calls
    assert bot.calls["sendMessage"]["text"] == "Hi John"