Commit 34653821 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Do not find new dependency IDs when there are unconnected p: tags

Suppose the task:

Some item p:1

(there is no parent). Then the next time a new ID is selected, it would
return 1 because there is no id: tag with value 1. However, this will
result in an invalid dependency.
parent 8fd0a6ff
......@@ -249,6 +249,7 @@ class TodoListDependencyTester(TopydoTest):
self.todolist.add("Another one with +Project")
self.todolist.add("Todo with +AnotherProject")
self.todolist.add("Todo without children id:3")
self.todolist.add("Orphan p:4")
def test_check_dep(self):
children = self.todolist.children(self.todolist.todo(1))
......@@ -279,8 +280,8 @@ class TodoListDependencyTester(TopydoTest):
todo5 = self.todolist.todo(5)
self.todolist.add_dependency(todo5, todo4)
self.assertTrue(todo5.has_tag('id', '4'))
self.assertTrue(todo4.has_tag('p', '4'))
self.assertTrue(todo5.has_tag('id', '5'))
self.assertTrue(todo4.has_tag('p', '5'))
def test_add_dep2(self):
"""
......@@ -294,8 +295,8 @@ class TodoListDependencyTester(TopydoTest):
self.todolist.add_dependency(todo5, todo4)
self.todolist.add_dependency(todo4, todo1)
self.assertTrue(todo4.has_tag('id', '5'))
self.assertTrue(todo1.has_tag('p', '5'))
self.assertTrue(todo4.has_tag('id', '6'))
self.assertTrue(todo1.has_tag('p', '6'))
def test_add_dep3(self):
"""
......
......@@ -117,7 +117,8 @@ class TodoList(TodoListBase):
Returns True if there exists a todo with the given parent ID.
"""
for todo in self._todos:
if todo.has_tag('id', str(p_id)):
number = str(p_id)
if todo.has_tag('id', number) or todo.has_tag('p', number):
return True
return False
......
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