Commit 9e1bdfa6 authored by MinchinWeb's avatar MinchinWeb

Allow iteration of TodoList items.

parent 473204aa
......@@ -234,6 +234,19 @@ class TodoListTester(TopydoTest):
self.assertNotEqual(self.todolist.number(todo), 't5c')
def test_iteration(self):
""" Confirms that the iternation method is working. """
results = ["(C) Foo @Context2 Not@Context +Project1 Not+Project",
"(D) Bar @Context1 +Project2",
"(C) Baz @Context1 +Project1 key:value",
"(C) Drink beer @ home",
"(C) 13 + 29 = 42"]
i = 0
for todo in self.todolist:
self.assertEqual(todo.src, results[i])
i += 1
class TodoListDependencyTester(TopydoTest):
def setUp(self):
......@@ -402,6 +415,7 @@ class TodoListDependencyTester(TopydoTest):
self.assertTrue(self.todolist.dirty)
self.assertTrue(self.todolist.todo_by_dep_id('99'))
class TodoListCleanDependencyTester(TopydoTest):
"""
Tests for cleaning up the graph:
......
......@@ -29,4 +29,3 @@ class PrettyPrinterFilter(object):
Applies a filter to p_todo_str and returns a modified version of it.
"""
raise NotImplementedError
......@@ -54,6 +54,12 @@ class TodoListBase(object):
self.add_list(p_todostrings)
self.dirty = False
def __iter__(self):
"""
Allows use of `for my_todo in todolist` constructs.
"""
return iter(self._todos)
def todo(self, p_identifier):
"""
The _todos list has the same order as in the backend store (usually
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment