Beispiel #1
0
def test_todo_ls():
    tmp = mktmpdir()

    todo_file = create_todo_file(tmp, todo_content_complex)

    tasks, last_index = TaskParserGenerator(todo_file).parse()
    todo = Todo.TodoCommands(tasks, last_index)

    output = cStringIO.StringIO()
    saveout = sys.stdout
    sys.stdout = output
    todo.ls('')

    result = output.getvalue()
    sys.stdout = saveout
    
    want = """  1: test-task-1
  2: test-task-2
@test-project-1
  3: test-task-3
  4: test-task-4
@test-project-2
  5: test-task-5
"""

    assert want == result
    output.close()
Beispiel #2
0
def test_todo_add_to_new_project():
    tmp = mktmpdir()

    todofile = create_todo_file(tmp, todo_content_complex)

    parsergenerator = TaskParserGenerator(todofile)
    tasks, lastindex = parsergenerator.parse()
    todo = Todo.TodoCommands(tasks, lastindex)

    todo.add(('@test-project-3', 'hello there world'))
    parsergenerator.generate(tasks)

    with file(todofile) as fobj:
        want = ( "$version 1",
                 "A - - test-task-1",
                 "B - - test-task-2",
                 "@test-project-1",
                 "B - - test-task-4",
                 "C - - test-task-3",
                 "@test-project-2",
                 "B - - test-task-5",
                 "@test-project-3",
                 "C - - hello there world"
                 )
        result = fobj.read()
        assert result == '\n'.join(want) + '\n'
Beispiel #3
0
def test_todo_pri():
    tmp = mktmpdir()

    todofile = create_todo_file(tmp, todo_content_complex)

    parsergenerator = TaskParserGenerator(todofile)
    tasks, lastindex = parsergenerator.parse()
    todo = Todo.TodoCommands(tasks, lastindex)

    todo.pri(['@test-project-1', "A"])
    parsergenerator.generate(tasks)

    with file(todofile) as fobj:
        want = ( "$version 1",
                 "A - - test-task-1",
                 "B - - test-task-2",
                 "@test-project-1",
                 "A - - test-task-3",
                 "A - - test-task-4",
                 "@test-project-2",
                 "B - - test-task-5")
        result = fobj.read()
        assert result == '\n'.join(want) + '\n'