Commit 59ba85de authored by Bram Schoenmakers's avatar Bram Schoenmakers

Properly deal with after: before: tags when a textual ID was given.

parent a4427f95
......@@ -18,6 +18,7 @@ from datetime import date
from topydo.lib import AddCommand
import CommandTest
from topydo.lib.Config import config
from topydo.lib import TodoList
class AddCommandTest(CommandTest.CommandTest):
......@@ -157,6 +158,18 @@ class AddCommandTest(CommandTest.CommandTest):
self.assertEquals(self.todolist.todo(3).source(), self.today + " Baz id:1")
self.assertEquals(self.errors, "")
def test_add_dep8(self):
config("test/data/todolist-uid.conf")
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command.execute()
command = AddCommand.AddCommand(["Bar after:tpi"], self.todolist, self.out, self.error)
command.execute()
self.assertEquals(self.todolist.todo('tpi').source(), "{} Foo p:1".format(self.today))
self.assertEquals(self.todolist.todo('b0n').source(), "{} Bar id:1".format(self.today))
def test_add_reldate1(self):
command = AddCommand.AddCommand(["Foo due:today"], self.todolist, self.out, self.error)
command.execute()
......
......@@ -61,21 +61,18 @@ class AddCommand(Command):
self.todo.set_tag(p_tag, dateobj.isoformat())
def add_dependencies(p_tag):
for raw_value in self.todo.tag_values(p_tag):
for value in self.todo.tag_values(p_tag):
try:
value = int(raw_value)
dep = self.todolist.todo(value)
if p_tag == 'after':
self.todolist.add_dependency(self.todo, dep)
elif p_tag == 'before' or p_tag == 'partof':
self.todolist.add_dependency(dep, self.todo)
except ValueError:
continue
except InvalidTodoException:
pass
self.todo.remove_tag(p_tag, raw_value)
self.todo.remove_tag(p_tag, value)
convert_date(config().tag_start())
convert_date(config().tag_due())
......
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