def test_create_Task_list_returns_4_tasks_with_completed_before(
        tasks_with_dates):
    dates = initialize_dates(completed_before='8/7/18')

    task_list = create_Task_list(tasks_with_dates, dates=dates)

    assert len(task_list) == 4
def test_create_Task_list_returns_6_tasks_with_completed_after(
        tasks_with_dates):
    dates = initialize_dates(completed_after='8/5/18')

    task_list = create_Task_list(tasks_with_dates, dates=dates)

    assert len(task_list) == 6
def test_create_Task_list_returns_one_task_with_correct_completed_date():
    tasks = []
    tasks.append(mock_rtm_taskseries(1, 'do this', completed=today))

    task_list = create_Task_list(make_list_of_rtm_lists(tasks),
                                 dates=initialize_dates())

    assert task_list[0].completed == today
def test_create_Task_list_returns_1_task():
    tasks = []
    tasks.append(mock_rtm_taskseries(1, 'do this'))

    task_list = create_Task_list(make_list_of_rtm_lists(tasks),
                                 dates=initialize_dates())

    assert len(task_list) == 1
def test_split_list(tasks_with_dates):
    tasks = create_Task_list(tasks_with_dates, dates=initialize_dates())
    incomplete_tasks, completed_tasks = split_list(tasks)

    failures = 0
    if len(incomplete_tasks) != 8:
        failures += 1
    if len(completed_tasks) != 8:
        failures += 1

    assert failures == 0
def test_create_Task_list_returns_one_task_with_completed_date():
    tasks = []
    tasks.append(mock_rtm_taskseries(1, 'do this', completed=today_str))
    tasks.append(mock_rtm_taskseries(2, 'do that', completed=yesterday_str))
    tasks.append(mock_rtm_taskseries(3, 'do nothing', completed=yesterday_str))

    dates = initialize_dates(completed_on='today')

    task_list = create_Task_list(make_list_of_rtm_lists(tasks), dates=dates)

    assert len(task_list) == 1
def test_create_Task_list_returns_one_task_with_correct_due_and_completed_date(
):
    tasks = []
    tasks.append(
        mock_rtm_taskseries(1, 'do this', due=yesterday, completed=today))

    task_list = create_Task_list(make_list_of_rtm_lists(tasks),
                                 dates=initialize_dates())

    failure = 0
    if task_list[0].completed != today or task_list[0].due != yesterday:
        failure = 1

    assert failure == 0
def test_create_Task_list_returns_10_tasks():
    tasks = []
    tasks.append(mock_rtm_taskseries(1, 'one'))
    tasks.append(mock_rtm_taskseries(2, 'two'))
    tasks.append(mock_rtm_taskseries(3, 'three'))
    tasks.append(mock_rtm_taskseries(4, 'four'))
    tasks.append(mock_rtm_taskseries(5, 'five'))
    tasks.append(mock_rtm_taskseries(6, 'six'))
    tasks.append(mock_rtm_taskseries(7, 'seven'))
    tasks.append(mock_rtm_taskseries(8, 'eight'))
    tasks.append(mock_rtm_taskseries(9, 'nine'))
    tasks.append(mock_rtm_taskseries(10, 'ten'))

    task_list = create_Task_list(make_list_of_rtm_lists(tasks),
                                 dates=initialize_dates())

    assert len(task_list) == 10
def test_create_Task_list_no_tasks_meeting_filters_raises_NoTasksException(
        tasks_with_dates):
    dates = initialize_dates(due_after='8/9/18')
    with pytest.raises(NoTasksException):
        task_list = create_Task_list(tasks_with_dates, dates=dates)
def test_create_Task_list_no_tasks_meeting_filters_raises_NoTasksException(
        tasks_with_dates):
    dates = initialize_dates(completed_before='8/5/18')
    with pytest.raises(NoTasksException):
        task_list = create_Task_list(tasks_with_dates, dates=dates)
def test_create_Task_list_between_dates(tasks_with_dates):
    dates = initialize_dates(due_after='8/6/18', due_before='8/9/18')

    task_list = create_Task_list(tasks_with_dates, dates=dates)

    assert len(task_list) == 4
def test_create_Task_list_with_tags_desired_raises_exception(tasks_with_tags):
    with pytest.raises(NoTasksException):
        task_list = create_Task_list(tasks_with_tags,
                                     tag='errands',
                                     dates=initialize_dates())
def test_create_Task_list_with_tags_desired_returns_2_tasks(tasks_with_tags):
    task_list = create_Task_list(tasks_with_tags,
                                 tag='work',
                                 dates=initialize_dates())

    assert len(task_list) == 2
def test_create_Task_list_empty_task_list_raises_NoTasksException():
    with pytest.raises(NoTasksException):
        create_Task_list([])