def on_users_callback(update: Update, context: CallbackContext) -> None: # pragma: no cover if str(update.message.chat_id) == config.ADMIN_CHAT_ID: users = list(dao.get_all_users()) msg = utils.build_users_msg(users) else: msg = "Loitering around my github?\nDon't hesitate greeting me! 😀" update.message.reply_text(msg)
def test_build_users_msg(): users = [{ 'name': 'romanito', 'isActive': True, 'chatId': 'aChatId' }, { 'name': 'pinxulino', 'isActive': False, 'chatId': 'aChatId2' }] res = utils.build_users_msg(users) tc.assertEqual( res, "Users: (2)" "\n- aChatId romanito 😀" "\n- aChatId2 pinxulino 😴")
def test_build_users_msg(): users = [{ 'name': 'romanito', 'isActive': True, 'chatId': 'aChatId' }, { 'name': 'pinxulino', 'isActive': False, 'chatId': 'aChatId2', 'levels': ['beginner', "intermediate"] }] res = utils.build_users_msg(users) tc.assertEqual( res, "Users: (2)" "\n- aChatId romanito 😀 " "\n- aChatId2 pinxulino 😴 bi")
def callback_on_users(self, update: Update, context: CallbackContext) -> None: # pragma: no cover users = list(self.dao.get_all_users()) msg = utils.build_users_msg(users) update.message.reply_text(msg)