Mock classes defined in test_utils.py are inconsistent with the way that python-telegram-bot api works. The initial work on the mocks is based on wrong assumption on which later additions have been added. For example Current MockUpdate is mostly used in a way, where each message from user shares same update even though in the real python-telegram-bot api each message is contained in it's own message. This causes weird situtations when testing more complex systems and need for better test framework came when DailyQuestion was implemented.
For example a snippet from DailyQuestion related test:
So at the moment the tests are messy and hard to upkeep and they do not provide enough abstraction to make it easy to write tests without having exact knowledge of the python-telegram-bot or implementation of current message_handler.
Solution
Easy to use test tools that follows api provided by python-telegram-bot framework
Requirements:
Core:
Uses pythons Mocks as a base with corresponding ptb classes as spec
Supports single chat context
Supports multiple users
Chat context keeps track of users, their messages, all messages in chat
message_id is tracked sy sequence in chat context
Chat context keeps track of current datetime (when initiated, clock is started. Objects created in the chat context use datetime relative to the chat's datetime)
Supports replying to any user's or bot's message by any user
Supports editing message by any user
Supports easy traversing bot's command activity menus (labels should be moved to the state modules and referenced from there)
Optional:
Supports multiple chat contexts (for example user interacts with bot in group chat and in private chat in the same test)
Problem:
Mock classes defined in test_utils.py are inconsistent with the way that python-telegram-bot api works. The initial work on the mocks is based on wrong assumption on which later additions have been added. For example Current MockUpdate is mostly used in a way, where each message from user shares same update even though in the real python-telegram-bot api each message is contained in it's own message. This causes weird situtations when testing more complex systems and need for better test framework came when DailyQuestion was implemented.
For example a snippet from DailyQuestion related test:
When it could be something like:
So at the moment the tests are messy and hard to upkeep and they do not provide enough abstraction to make it easy to write tests without having exact knowledge of the python-telegram-bot or implementation of current message_handler.
Solution
Easy to use test tools that follows api provided by python-telegram-bot framework
Requirements:
Core:
Optional: