Commit a0fafb05 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Store edge IDs as integer in the dependency graph.

add_dependency would store them as strings. On the next invocation
of add_dependency, find_new_id wouldn't find the previously stored
value since it looks for integers. Therefore it returns the same
ID, resulting in duplicate edge IDs.
parent bce6f88d
......@@ -196,7 +196,7 @@ class TodoList(object):
from_todo.set_tag('id', dep_id)
to_todo.add_tag('p', dep_id)
self._depgraph.add_edge(p_number1, p_number2, int(dep_id))
self._depgraph.add_edge(p_number1, p_number2, dep_id)
self._update_parent_cache()
def remove_dependency(self, p_number1, p_number2):
......
......@@ -167,12 +167,24 @@ class TodoListDependencyTester(unittest.TestCase):
self.assertEqual(self.todolist.children(2), [])
self.assertEqual(self.todolist.parents(1), [])
def test_add_dep(self):
def test_add_dep1(self):
self.todolist.add_dependency(5, 4)
self.assertTrue(self.todolist.todo(5).has_tag('id', '3'))
self.assertTrue(self.todolist.todo(4).has_tag('p', '3'))
def test_add_dep2(self):
"""
Make sure that previous add_dependency invocation stored the
edge_id properly.
"""
self.todolist.add_dependency(5, 4)
self.todolist.add_dependency(4, 1)
self.assertTrue(self.todolist.todo(4).has_tag('id', '4'))
self.assertTrue(self.todolist.todo(1).has_tag('p', '4'))
def test_remove_dep1(self):
self.todolist.remove_dependency(3, 4)
......
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