Ejemplo n.º 1
0
 def user_add_before(self):
     """The user is added before the start of the verification.
     """
     if add_user_to_database(telegramm_user_id, first_name, last_name, username, chat_id):
         print("User for testing added")
     else:
         print("Error")
Ejemplo n.º 2
0
 def user_add_after(self):
     """The user is added after the verification.
     """
     yield
     if add_user_to_database(telegramm_user_id, first_name, last_name, username, chat_id):
         print("User for testing added")
     else:
         print("Error")
Ejemplo n.º 3
0
def join_user(bot: Bot, update: Update, user_data: dict) -> Message:
    """The function is adding user in the database.
    :param bot: Bot
    :param update: Update
    :param user_data: User data
    :return: If the user is not in the database, the function add
             user to database and sends a greet message to the user.
             If an error occurs during adding, an error message 
             is sent to the user. 
    """
    if add_user_to_database(update.effective_user.id,
                            update.effective_user.first_name,
                            update.effective_user.last_name,
                            update.effective_user.username,
                            update.message.chat_id):
        text_message = settings.ADD_USER
    else:
        text_message = settings.ADD_ERROR

    update.message.reply_text(text_message, reply_markup=reminder_keyboard())
Ejemplo n.º 4
0
 def test_add_user_to_database(self, user_delete_after):
     """Testing adding a user to the database. 
        If the user is added without errors, the function returns True.
     """
     assert add_user_to_database(telegramm_user_id, first_name, last_name, username, chat_id) == True
Ejemplo n.º 5
0
 def setUpClass(cls):
     if add_user_to_database(1111,'Test_name', 'Test_surname', 'Test_nickname', 1111):
         print("User for testing added")
Ejemplo n.º 6
0
 def test_add_user_to_database(self):
     self.assertTrue(add_user_to_database(1111,'Test_name', 'Test_surname', 'Test_nickname', 1111))