def test_set_status(toodledo):
    task = CreateATask(toodledo, Task(status=Status.NEXT_ACTION))
    toodledo.DeleteTasks([task])

    task = CreateATask(toodledo, Task(status=Status.NONE))
    toodledo.DeleteTasks([task])

    task = CreateATask(toodledo, Task(status=Status.WAITING))
    toodledo.DeleteTasks([task])
def test_set_due_date_modifier(toodledo):
    task = CreateATask(
        toodledo,
        Task(dueDate=date.today(), dueDateModifier=DueDateModifier.DUE_AFTER))
    toodledo.DeleteTasks([task])

    task = CreateATask(
        toodledo,
        Task(dueDate=date.today(), dueDateModifier=DueDateModifier.DUE_ON))
    toodledo.DeleteTasks([task])
def test_extra_fields(toodledo):
    randomTitle = str(uuid4())
    toodledo.AddTasks([Task(title=randomTitle)])
    tasks = toodledo.GetTasks(params={"fields": "tag,duedate,startdate"})
    assert isinstance(tasks, list)
    assert len(tasks) >= 1

    # find our tasks
    ourTasks = [t for t in tasks if t.title == randomTitle]
    assert len(ourTasks) == 1
    task = ourTasks[0]

    assert hasattr(task, "title")
    assert hasattr(task, "id_")
    assert hasattr(task, "modified")
    assert hasattr(task, "completedDate")
    assert hasattr(task, "startDate")
    assert hasattr(task, "dueDate")
    assert hasattr(task, "tags")

    assert task.title == randomTitle

    # clean up
    toodledo.DeleteTasks([task])

    # find our tasks again
    tasks = toodledo.GetTasks(params={})
    ourTasks = [t for t in tasks if t.title == randomTitle]
    assert len(ourTasks) == 0
def test_set_note(toodledo):
    task = CreateATask(toodledo, Task(note="This is a note"))
    toodledo.DeleteTasks([task])
def test_set_length(toodledo):
    task = CreateATask(toodledo, Task(length=42))
    toodledo.DeleteTasks([task])
def test_set_star(toodledo):
    task = CreateATask(toodledo, Task(star=True))
    toodledo.DeleteTasks([task])

    task = CreateATask(toodledo, Task(star=False))
    toodledo.DeleteTasks([task])
def test_set_tags(toodledo):
    task = CreateATask(toodledo, Task(tags=["a", "b", "c"]))
    toodledo.DeleteTasks([task])

    task = CreateATask(toodledo, Task(tags=["z", "a", "b", "c"]))
    toodledo.DeleteTasks([task])
def test_set_due_date(toodledo):
    task = CreateATask(toodledo, Task(dueDate=date.today()))
    toodledo.DeleteTasks([task])
def test_set_priority(toodledo):
    task = CreateATask(toodledo, Task(priority=Priority.HIGH))
    toodledo.DeleteTasks([task])

    task = CreateATask(toodledo, Task(priority=Priority.NEGATIVE))
    toodledo.DeleteTasks([task])
def test_set_parent(toodledo):
    task = CreateATask(toodledo, Task(parent=12345))
    toodledo.DeleteTasks([task])
def test_set_repeat(toodledo):
    task = CreateATask(toodledo, Task(repeat="FREQ=YEARLY"))
    toodledo.DeleteTasks([task])