test_Commands.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:secreth_telegrambot 作者: d0tcc 项目源码 文件源码
def test_ping(self):
        # Then register the handler with he updater's dispatcher and start polling
        self.updater.dispatcher.add_handler(CommandHandler("ping", command_ping))
        self.updater.start_polling()
        # create with random user
        update = self.mg.get_message(text="/ping")
        # We insert the update with the bot so the updater can retrieve it.
        self.bot.insertUpdate(update)
        # sent_messages is the list with calls to the bot's outbound actions. Since we hope the message we inserted
        # only triggered one sendMessage action it's length should be 1.
        self.assertEqual(len(self.bot.sent_messages), 1)
        sent = self.bot.sent_messages[0]
        self.assertEqual(sent['method'], "sendMessage")
        self.assertEqual(sent['text'], "pong - v0.4")
        # Always stop the updater at the end of a testcase so it won't hang.
        self.updater.stop()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号