def test_complete(self): """completion""" todo_line = "x foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.done, True) self.assertEqual(task.finish, None) todo_line = "x 2013-12-15 foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.done, True) self.assertEqual(task.finish, date(2013,12,15))
def test_dates(self): """date handling""" todo_line = "2010-2-23 foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.create, date(2010,2,23)) todo_line = "x 2010-2-23 foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.finish, date(2010,2,23)) self.assertEqual(task.create, None) todo_line = "x 2010-2-23 2010-2-22 foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.finish, date(2010,2,23)) self.assertEqual(task.create, date(2010,2,22))
def test_leading_space(self): """leading spaces""" todo_line = " foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.priority, "") self.assertEqual(task.create, None) self.assertEqual(task.finish, None) self.assertEqual(task.done, False) self.assertEqual(task.task, " foo bar") self.assertEqual(set(task.projects), set(["+proj1", "+proj2"])) self.assertEqual(set(task.contexts), set(["@context"])) self.assertEqual(task.tags, {"tag":"value"}) todo_line = " (A) foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.priority, "") self.assertEqual(task.create, None) self.assertEqual(task.finish, None) self.assertEqual(task.done, False) self.assertEqual(task.task, " (A) foo bar") self.assertEqual(set(task.projects), set(["+proj1", "+proj2"])) self.assertEqual(set(task.contexts), set(["@context"])) self.assertEqual(task.tags, {"tag":"value"}) todo_line = " x foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.priority, "") self.assertEqual(task.create, None) self.assertEqual(task.finish, None) self.assertEqual(task.done, False) self.assertEqual(task.task, " x foo bar") self.assertEqual(set(task.projects), set(["+proj1", "+proj2"])) self.assertEqual(set(task.contexts), set(["@context"])) self.assertEqual(task.tags, {"tag":"value"}) todo_line = " 2010-10-2 foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.priority, "") self.assertEqual(task.create, date(2010,10,2)) self.assertEqual(task.finish, None) self.assertEqual(task.done, False) self.assertEqual(task.task, " foo bar") self.assertEqual(set(task.projects), set(["+proj1", "+proj2"])) self.assertEqual(set(task.contexts), set(["@context"])) self.assertEqual(task.tags, {"tag":"value"})
def test_task(self): """basic task parsing""" todo_line = "foo bar +proj1 +proj2 @context tag:value" task = Task.parse(todo_line) self.assertEqual(task.priority, "") self.assertEqual(task.create, None) self.assertEqual(task.finish, None) self.assertEqual(task.done, False) self.assertEqual(task.task, "foo bar") self.assertEqual(set(task.projects), set(["+proj1", "+proj2"])) self.assertEqual(set(task.contexts), set(["@context"])) self.assertEqual(task.tags, {"tag":"value"})
def test_empty_line(self): x = Task.parse("") self.assertEqual(x, None)