Exemplo n.º 1
0
 def test_check_minutes_remaining(self):
     today_date = datetime.now()
     source_data = {'date': datetime.strftime(today_date, '%d-%m-%Y'),
                    'hours': datetime.now().hour}
     step = 5
     convert_minute = (((datetime.now().minute // step) + 1) * step)
     self.assertEqual(minute_remaining(source_data, step), convert_minute)
Exemplo n.º 2
0
 def test_check_minutes_remaining_error(self):
     """
     The function should return 0 if an error occurred during processing.
     """
     today_date = datetime.now()
     source_data = {'date': datetime.strftime(today_date, '%d-%M-%Y'),
                    'hours': datetime.now().hour}
     assert minute_remaining(source_data, 5) == 0
Exemplo n.º 3
0
 def test_check_minutes_remaining_tommorow(self):
     """The function should return 0 if tomorrow's date is passed.
     """
     source_data = {'day': (datetime.now() + timedelta(days=1)).day,
                    'month': datetime.now().month,
                    'year': datetime.now().year,
                    'hours': datetime.now().hour}
     assert minute_remaining(source_data, 5) == 0
Exemplo n.º 4
0
 def test_check_minutes_remaining_manual(self):
     source_data = {'day': datetime.now().day,
                    'month': datetime.now().month,
                    'year': datetime.now().year,
                    'hours': datetime.now().hour}
     step = 5
     convert_minute = (((datetime.now().minute // step) + 1) * step) 
     self.assertEqual(minute_remaining(source_data, step), convert_minute)
Exemplo n.º 5
0
 def test_check_minutes_remaining(self):
     """The function should return the current minutes with the given 
        step when transmitting a dictionary containing the "date" field
        and date-today.
        In the current example, step 5.
        If the current time is 10:02, the function should return 5, 
        if the time is 11:28, then the function should return 30.
     """
     today_date = datetime.now()
     source_data = {'date': datetime.strftime(today_date, '%d-%m-%Y'),
                    'hours': datetime.now().hour}
     step = 5
     convert_minute = (((datetime.now().minute // step) + 1) * step)
     assert minute_remaining(source_data, step) == convert_minute
Exemplo n.º 6
0
 def test_check_minutes_remaining_manual(self):
     """The function should return the current minutes with the given 
        step when transmitting a dictionary containing the 
        "day", "month", "year", "hours" field and date-today.
        In the current example, step 5.
        If the current time is 10:02, the function should return 5, 
        if the time is 11:28, then the function should return 30.
     """
     source_data = {'day': datetime.now().day,
                    'month': datetime.now().month,
                    'year': datetime.now().year,
                    'hours': datetime.now().hour}
     step = 5
     convert_minute = (((datetime.now().minute // step) + 1) * step) 
     assert minute_remaining(source_data, step) == convert_minute
Exemplo n.º 7
0
def manual_add_date_hour(bot: Bot, update: Update, user_data: dict) -> str:
    """The function adds hour to the dictionary 
       user_data and sends a message to the user with a request to enter minute.

    :param bot: Bot
    :param update: Update
    :param user_data: User data
    :return: The function sends a message to the user with a request 
             to enter a minute. 
    """
    user_data['hours'] = update.message.text
    start_minute = minute_remaining(user_data, 5)
    text_message = settings.ENTER_MINUTES
    update.message.reply_text(
        text_message,
        reply_markup=reminder_add_digital_period_keyboard(
            start_minute, 59, 10, 5))

    return "manual_add_date_minute"
Exemplo n.º 8
0
 def test_check_minutes_remaining_error(self):
     today_date = datetime.now()
     source_data = {'date': datetime.strftime(today_date, '%d-%M-%Y'),
                    'hours': datetime.now().hour}
     self.assertEqual(minute_remaining(source_data, 5), 0)
Exemplo n.º 9
0
 def test_check_minutes_remaining_tommorow(self):
     source_data = {'day': (datetime.now() + timedelta(days=1)).day,
                    'month': datetime.now().month,
                    'year': datetime.now().year,
                    'hours': datetime.now().hour}
     self.assertEqual(minute_remaining(source_data, 5), 0)