Example #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()
Example #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'
def setup():
    # necessary for style().standardIcon()
    if QApplication.type() != QApplication.GuiClient:
        raise SkipTest

    global _tmpdir
    _tmpdir = helpers.mktmpdir(__name__)
Example #4
0
def test_task_parser_missing_version():
    tmpdir = mktmpdir()
    todo_file = os.path.join(tmpdir, 'todo')
    with file(todo_file, 'w') as f:
        f.write('\n'.join(todo_content_complex[1:]))

    taskparsergenerator = TaskParserGenerator(todo_file)
    with want_exception(ValueError('incorrect version in todo file')):
        tasks, _ = taskparsergenerator.parse()
def test_task_parser_missing_version():
    tmpdir = mktmpdir()
    todo_file = os.path.join(tmpdir, 'todo')
    with file(todo_file, 'w') as f:
        f.write('\n'.join(todo_content_complex[1:]))

    taskparsergenerator = TaskParserGenerator(todo_file)
    with want_exception(
        ValueError('incorrect version in todo file')
        ):
        tasks, _ = taskparsergenerator.parse()
Example #6
0
def check_content(content):
    tmpdir = mktmpdir()
    todo_file = os.path.join(tmpdir, 'todo')
    with file(todo_file, 'w') as f:
        f.write('\n'.join(content))

    tasks, _ = TaskParserGenerator(todo_file).parse()

    with file(todo_file) as f:
        want = '\n'.join(content)
        result = f.read()
        assert want == result
def check_content(content):
    tmpdir = mktmpdir()
    todo_file = os.path.join(tmpdir, 'todo')
    with file(todo_file, 'w') as f:
        f.write('\n'.join(content))
    
    tasks, _ = TaskParserGenerator(todo_file).parse()

    with file(todo_file) as f:
        want = '\n'.join(content)
        result = f.read()
        assert want == result
Example #8
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'
Example #9
0
def setup():
    global _tmpdir
    _tmpdir = helpers.mktmpdir(__name__)

    # foo0 -- foo1 ---------- foo3 -------------------------- foo7
    #   \       \
    #    \       -------------------- baz4 -- baz5 -- baz6 --------
    #     \                                        /               \
    #      ---------- bar2 ------------------------------------------ bar8
    #       [branch: bar]
    hg = helpers.HgClient(os.path.join(_tmpdir, 'named-branch'))
    hg.init()
    hg.fappend('data', 'foo0')
    hg.commit('-Am', 'foo0')
    hg.fappend('data', 'foo1\n')
    hg.commit('-m', 'foo1')
    hg.update('0')
    hg.branch('bar')
    hg.fappend('data', 'bar2\n')
    hg.commit('-m', 'bar2')
    hg.update('1')
    hg.fappend('data', 'foo3\n')
    hg.commit('-m', 'foo3')
    hg.update('1')
    hg.fappend('data', 'baz4\n')
    hg.commit('-m', 'baz4')
    hg.fappend('data', 'baz5\n')
    hg.commit('-m', 'baz5')
    hg.merge('--tool=internal:local', '2')
    hg.commit('-m', 'baz6')
    hg.update('3')
    hg.fappend('data', 'foo7\n')
    hg.commit('-m', 'foo7')
    hg.update('2')
    hg.merge('--tool=internal:local', '6')
    hg.commit('-m', 'bar8')
Example #10
0
def setup():
    global _tmpdir
    _tmpdir = helpers.mktmpdir(__name__)

    # foo0 -- foo1 ---------- foo3 -------------------------- foo7
    #   \       \
    #    \       -------------------- baz4 -- baz5 -- baz6 --------
    #     \                                        /               \
    #      ---------- bar2 ------------------------------------------ bar8
    #       [branch: bar]
    hg = helpers.HgClient(os.path.join(_tmpdir, 'named-branch'))
    hg.init()
    hg.fappend('data', 'foo0')
    hg.commit('-Am', 'foo0')
    hg.fappend('data', 'foo1\n')
    hg.commit('-m', 'foo1')
    hg.update('0')
    hg.branch('bar')
    hg.fappend('data', 'bar2\n')
    hg.commit('-m', 'bar2')
    hg.update('1')
    hg.fappend('data', 'foo3\n')
    hg.commit('-m', 'foo3')
    hg.update('1')
    hg.fappend('data', 'baz4\n')
    hg.commit('-m', 'baz4')
    hg.fappend('data', 'baz5\n')
    hg.commit('-m', 'baz5')
    hg.merge('--tool=internal:local', '2')
    hg.commit('-m', 'baz6')
    hg.update('3')
    hg.fappend('data', 'foo7\n')
    hg.commit('-m', 'foo7')
    hg.update('2')
    hg.merge('--tool=internal:local', '6')
    hg.commit('-m', 'bar8')
 def setUp(self):
     if not hasattr(wconfig.config(), 'write'):
         raise SkipTest
     self.hg = helpers.HgClient(helpers.mktmpdir(__name__))
     self.hg.init()
Example #12
0
def setup():
    global _tempdir
    _tempdir = helpers.mktmpdir(__name__)
Example #13
0
def setup():
    global _tmpdir
    _tmpdir = helpers.mktmpdir(__name__)
 def setUp(self):
     if not hasattr(wconfig.config(), 'write'):
         raise SkipTest
     self.hg = helpers.HgClient(helpers.mktmpdir(__name__))
     self.hg.init()