def test_tree_root_nodes(self): self.maxDiff = None root_nodes = NeedHelp.objects.root_nodes() btn_text = [i.user_input for i in root_nodes if not i.is_default] # print(btn_text) for i, btn_name in enumerate(btn_text, 1): self.assertEqual(keyboard_button(btn_name, i), btn_input(btn_name))
def start(update, context): _chat_id = update.message.chat_id try: key_bord_btn, help_text = keyboard_button(update.message.text, _chat_id) except Exception as ex: logger_telegram().exception("Exception TelegramBot.start().\n%s" % ex) else: try: context.bot.send_message( chat_id=_chat_id, text=help_text, parse_mode=ParseMode.HTML, disable_web_page_preview=True, reply_markup=ReplyKeyboardMarkup(key_bord_btn, resize_keyboard=True), ) except Exception as ex: logger_telegram().exception("Exception TelegramBot.start().\n%s" % ex)
def test_text_input(self): self.maxDiff = None btn_name = 'Юридическая помощь' self.assertEqual(keyboard_button(btn_name, 123456), btn_input(btn_name))
def test_one_character_input(self): self.maxDiff = None self.assertEqual(keyboard_button("1", 123456), zero_character_input())
def test_start_input(self): """ out == (btn_to_send, text_out) """ self.maxDiff = None self.assertEqual(keyboard_button("/start", 123456), start_msg())