def test_effective_message_type(self): test_message = Message(message_id=1, from_user=None, date=None, chat=None) test_message.text = 'Test' assert helpers.effective_message_type(test_message) == 'text' test_message.text = None test_message.sticker = Sticker('sticker_id', 50, 50) assert helpers.effective_message_type(test_message) == 'sticker' test_message.sticker = None test_message.new_chat_members = [User(55, 'new_user', False)] assert helpers.effective_message_type( test_message) == 'new_chat_members' test_update = Update(1) test_message.text = 'Test' test_update.message = test_message assert helpers.effective_message_type(test_update) == 'text' empty_update = Update(2) assert helpers.effective_message_type(empty_update) is None
def build_test_message(**kwargs): config = dict( message_id=1, from_user=None, date=None, chat=None, ) config.update(**kwargs) return Message(**config)
def __init__(self, data, db=None): self.__update_id = data['update_id'] if data.__contains__('message'): self.__message = Message(data['message'], db=db) else: self.__message = None if data.__contains__('inline_query'): self.__inline_query = None else: self.__inline_query = None if data.__contains__('chosen_inline_result'): self.__chosen_inline_result = None else: self.__chosen_inline_result = None