TestCases
Reusable testcases for Telegram bot app.
TelegramBotTestCase
¶
Bases: TestCase
Base test case for Telegram bot tests.
Source code in django_telegram_app/bot/testing/testcases.py
last_bot_message
property
¶
Return the last message sent by the bot.
This is a convenience property for tests and can be used to verify the last message.
Example
self.send_text("/start") self.assertEqual(self.last_bot_message, "Welcome to the bot!")
webhook_url
property
¶
Return the webhook URL.
click_on_button(button, verify=True)
¶
Simulate a click on an inline button by text or index.
When button is a string, it searches for a button with matching text.
When button is an integer, it treats it as the index of the button in
the inline keyboard (flattened).
Source code in django_telegram_app/bot/testing/testcases.py
click_on_text(text, verify=True)
¶
Simulate a click on the specified text button.
Source code in django_telegram_app/bot/testing/testcases.py
construct_telegram_callback_query(callback_data)
staticmethod
¶
Construct a minimal telegram callback query.
Source code in django_telegram_app/bot/testing/testcases.py
construct_telegram_update(message_text)
staticmethod
¶
post_data(data, verify=True)
¶
Post data to the webhook.