def test_get_due_tasks_update_date__task_overdue(self): target = datetime.date(2020, 4, 27) tasks_by_date = [ ["Sep 18 2018", "4w", "Example monthly task. Add tasks in this " \ "format, use w for weeks, d for days." ], ["Oct 2 2018", "5d", "Example task, written every 5 days." ] ] expected_tasks_by_date = [ ["May 25 2020", "4w", "Example monthly task. Add tasks in this " \ "format, use w for weeks, d for days."], ["May 02 2020", "5d", "Example task, written every 5 days."] ] expected_weeks_tasks = "Old task detected. Was due on Sep 18 2018" \ "(587 days ago): Example monthly task.\nAdd tasks in this " \ "format, use w for weeks, d for days.\nOld task detected. Was " \ "due on Oct 2 2018(573 days ago): Example task, written every 5 days.\n" result_task_by_date, result_weeks_tasks = reminder.get_due_tasks_update_date( target, tasks_by_date) self.assertEqual(expected_tasks_by_date, result_task_by_date) self.assertEqual(expected_weeks_tasks, result_weeks_tasks)
def test_get_due_tasks_update_date__task_not_due(self): target = datetime.date(2018, 8, 11) tasks_by_date = [["Sep 18 2018", "4w", "Example monthly task."]] expected_tasks_by_date = [[ "Sep 18 2018", "4w", "Example monthly task." ]] expected_weeks_tasks = "" result_task_by_date, result_weeks_tasks = reminder.get_due_tasks_update_date( target, tasks_by_date) self.assertEqual(expected_tasks_by_date, result_task_by_date) self.assertEqual(expected_weeks_tasks, result_weeks_tasks)
def test_get_due_tasks_update_date__due_list_task(self): target = datetime.date(2018, 9, 18) tasks_by_date = [["Sep 18 2018", "4w", "[Example, monthly, task.]"]] expected_tasks_by_date = [[ "Oct 16 2018", "4w", "[monthly, task., Example]" ]] expected_weeks_tasks = "Example\n" result_task_by_date, result_weeks_tasks = reminder.get_due_tasks_update_date( target, tasks_by_date) self.assertEqual(expected_tasks_by_date, result_task_by_date) self.assertEqual(expected_weeks_tasks, result_weeks_tasks)
def test_get_due_tasks_update_date__task_due_unittest(self, get_new_due_date, prepare_task_string, to_datetime_date): to_datetime_date.return_value = datetime.date(2018, 9, 18) prepare_task_string.return_value = "Example monthly task.\n" get_new_due_date.return_value = "Oct 16 2018" target = datetime.date(2018, 9, 18) tasks_by_date = [["Sep 18 2018", "4w", "Example monthly task."]] result_task_by_date, result_weeks_tasks = reminder.get_due_tasks_update_date(target, tasks_by_date) expected_tasks_by_date = [["Oct 16 2018", "4w", "Example monthly task."]] expected_weeks_tasks = "Example monthly task.\n" self.assertEqual(expected_tasks_by_date, result_task_by_date) self.assertEqual(expected_weeks_tasks, result_weeks_tasks)