def test_adding_bubbles(self, sending_message: SendingMessage) -> None: bubble = BubbleElement(command="/test") sending_message.markup = MessageMarkup() sending_message.add_bubble("/test") sending_message.add_bubble("/test", new_row=False) sending_message.add_bubble("/test") sending_message.add_bubble("/test") sending_message.add_bubble("/test", new_row=False) assert sending_message.markup == MessageMarkup( bubbles=[[bubble, bubble], [bubble], [bubble, bubble]], )
async def my_handler_with_passing_predefined_markup(message: Message) -> None: markup = MessageMarkup() markup.add_bubble(command="", label="bubble 1") markup.add_bubble(command="", label="bubble 2", new_row=False) markup.add_bubble(command="", label="bubble 3") await bot.answer_message("Bubbles!!", message, markup=markup)
def test_adding_keyboard(self, sending_message: SendingMessage) -> None: keyboard_button = KeyboardElement(command="/test") sending_message.markup = MessageMarkup() sending_message.add_keyboard_button("/test") sending_message.add_keyboard_button("/test", new_row=False) sending_message.add_keyboard_button("/test") sending_message.add_keyboard_button("/test") sending_message.add_keyboard_button("/test", new_row=False) assert sending_message.markup == MessageMarkup(keyboard=[ [keyboard_button, keyboard_button], [keyboard_button], [keyboard_button, keyboard_button], ], )
def sending_message() -> SendingMessage: return SendingMessage( text="text", file=File.from_string(b"data", filename="file.txt"), credentials=SendingCredentials( sync_id=uuid.uuid4(), bot_id=uuid.uuid4(), host="host", ), markup=MessageMarkup( bubbles=[[BubbleElement(command="")]], keyboard=[[KeyboardElement(command="")]], ), options=MessageOptions( recipients=[uuid.uuid4()], mentions=[ Mention(mention_data=UserMention(user_huid=uuid.uuid4())), Mention( mention_data=UserMention(user_huid=uuid.uuid4()), mention_type=MentionTypes.contact, ), Mention( mention_data=ChatMention(group_chat_id=uuid.uuid4()), mention_type=MentionTypes.chat, ), ], notifications=NotificationOptions(send=False, force_dnd=True), ), )
def test_message_markup_will_add_row_if_there_is_no_existed_and_not_new_row( ) -> None: markup1 = MessageMarkup() markup1.add_bubble("/command", new_row=False) markup2 = MessageMarkup() markup2.add_bubble("/command") assert markup1 == markup2
def test_adding_markup_by_elements() -> None: bubble = BubbleElement(command="/command") keyboard = KeyboardElement(command="/command") markup = MessageMarkup() markup.add_bubble_element(bubble) markup.add_keyboard_button_element(keyboard) assert markup == MessageMarkup(bubbles=[[bubble]], keyboard=[[keyboard]])
async def my_handler_with_direct_bubbles_definition(message: Message) -> None: await bot.answer_message( "Bubbles!!", message, markup=MessageMarkup(bubbles=[ [BubbleElement(label="bubble 1", command="")], [ BubbleElement(label="bubble 2", command=""), BubbleElement(label="bubble 3", command=""), ], ], ), )
def test_update_markup_will_can_be_set_from_markup() -> None: markup = MessageMarkup() markup.add_bubble("/command") markup.add_keyboard_button("/command") update = UpdatePayload() update.set_markup(markup) assert update.markup == markup assert update.bubbles == markup.bubbles assert update.keyboard == markup.keyboard
def test_message_markup(self, sending_message: SendingMessage) -> None: markup = MessageMarkup(bubbles=[[BubbleElement(command="/test")]]) sending_message.markup = markup assert sending_message.markup == markup