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()
评论列表
文章目录