def reminder(): """Page processing function "/reminder" The function, based on the user ID, requests reminders from the data. """ if current_user.is_authenticated: userid = request.args.get('userid', None) user_info = get_information_about_user(userid) list_reminders = reminder_list_from_database(userid) return render_template('reminder.html', title='List Reminder', reminder_list=list_reminders, user_info=user_info) return redirect(url_for('index'))
def greet_user(bot: Bot, update: Update, user_data: dict) -> Message: """Welcome function. Called upon message: /start :param bot: Bot :param update: Update :param user_data: User data :return: If the user is in the database, the function sends a welcome message to the user indicating his name or a welcome message with a proposal to be added to the database. """ if get_information_about_user(update.effective_user.id) is None: message_text = settings.JOIN_TEXT update.message.reply_text(message_text, reply_markup=starting_keyboard()) else: message_text = settings.JOIN_TEXT_FOR_USER.format( update.effective_user.first_name) update.message.reply_text(message_text, reply_markup=reminder_keyboard())
def test_check_user_in_database_bad_request(self): """Testing the user presence in the database. If the error is in the format or username, the function returns None. """ assert get_information_about_user(wrong_format_telegramm_user_id) == None
def test_check_user_in_database_none(self): """Testing the user presence in the database. If such a user is no in the database, the function returns None. """ assert get_information_about_user(wrong_telegramm_user_id) == None
def test_check_user_in_database_good(self, user_add_before, user_delete_after): """Testing the user presence in the database. If such a user is in the database, the function returns True. """ assert get_information_about_user(telegramm_user_id) == user_in_database
def test_check_user_in_database_bad_request(self): self.assertIsNone(get_information_about_user('dsfsdfs'))
def test_check_user_in_database_none(self): self.assertIsNone(get_information_about_user(2222))
def test_check_user_in_database_good(self): self.assertTrue(get_information_about_user(1111))
def tearDownClass(cls): if get_information_about_user(1111) is None: print("User for testing deleted")
def tearDownClass(cls): print(get_information_about_user(1111)) if delete_user_from_database(1111): print("User for testing is delete") else: print("Error")