示例#1
0
def test_from_todotxt(
    description, done, priority, completed_at, created_at, projects, contexts, tags
):
    task = Task.from_todotxt(
        todotxt(
            description,
            done,
            priority,
            completed_at,
            created_at,
            projects,
            contexts,
            tags,
        )
    )
    assert task.done == (done == "x")
    assert task.priority == priority
    assert task.completed_at == completed_at
    if created_at is None:
        assert task.created_at == datetime.now().date()
    else:
        assert task.created_at == created_at
    assert task.description == description
    assert task.projects == projects
    assert task.contexts == contexts
    assert task.tags == tags
示例#2
0
def test_completed_at_string(done, priority, completed_at, created_at, description):
    task = Task(
        done=done,
        priority=priority,
        completed_at=completed_at,
        created_at=created_at,
        description=description,
    )
    if completed_at:
        assert f"{completed_at.strftime('%Y-%m-%d')}" in str(task)
    assert str(task).endswith(minimal_text(created_at, description))
示例#3
0
def test_priority_string(done, priority, completed_at, created_at, description):
    task = Task(
        done=done,
        priority=priority,
        completed_at=completed_at,
        created_at=created_at,
        description=description,
    )
    if priority:
        assert f"({priority})" in str(task)
    assert str(task).endswith(minimal_text(created_at, description))
示例#4
0
def test_done_string(done, priority, completed_at, created_at, description):
    task = Task(
        done=done,
        priority=priority,
        completed_at=completed_at,
        created_at=created_at,
        description=description,
    )
    if done:
        assert str(task).startswith("x ")
    assert str(task).endswith(minimal_text(created_at, description))
示例#5
0
def test_tags_string(created_at, description, projects, contexts, tags):
    task = Task(
        created_at=created_at,
        description=description,
        projects=projects,
        contexts=contexts,
        tags=tags,
    )
    tags_text = ""
    for key, value in tags.items():
        tags_text += f" {key}:{value}"

    assert str(task).startswith(minimal_text(created_at, description))
    assert tags_text in str(task)
示例#6
0
def test_contexts_string(created_at, description, projects, contexts, tags):
    task = Task(
        created_at=created_at,
        description=description,
        projects=projects,
        contexts=contexts,
        tags=tags,
    )
    contexts_text = ""
    for context in contexts:
        contexts_text += f" @{context}"

    assert str(task).startswith(minimal_text(created_at, description))
    assert contexts_text in str(task)
示例#7
0
def test_minimal_string(created_at, description):
    task = Task(created_at=created_at, description=description)
    assert str(task) == minimal_text(created_at, description)
示例#8
0
def test_from_todotxt_with_date_tags():
    test_text = "2019-01-01 Test Task +Project1 due:2019-02-01"
    task = Task.from_todotxt(test_text)
    assert task.created_at == datetime(2019, 1, 1).date()
    assert task.completed_at is None
    assert task.tags == {"due": datetime(2019, 2, 1).date()}