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 ...@@ -18,6 +18,7 @@ from datetime import date
from topydo.lib import AddCommand from topydo.lib import AddCommand
import CommandTest import CommandTest
from topydo.lib.Config import config
from topydo.lib import TodoList from topydo.lib import TodoList
class AddCommandTest(CommandTest.CommandTest): class AddCommandTest(CommandTest.CommandTest):
...@@ -157,6 +158,18 @@ 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.todolist.todo(3).source(), self.today + " Baz id:1")
self.assertEquals(self.errors, "") 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): def test_add_reldate1(self):
command = AddCommand.AddCommand(["Foo due:today"], self.todolist, self.out, self.error) command = AddCommand.AddCommand(["Foo due:today"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -61,21 +61,18 @@ class AddCommand(Command): ...@@ -61,21 +61,18 @@ class AddCommand(Command):
self.todo.set_tag(p_tag, dateobj.isoformat()) self.todo.set_tag(p_tag, dateobj.isoformat())
def add_dependencies(p_tag): 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: try:
value = int(raw_value)
dep = self.todolist.todo(value) dep = self.todolist.todo(value)
if p_tag == 'after': if p_tag == 'after':
self.todolist.add_dependency(self.todo, dep) self.todolist.add_dependency(self.todo, dep)
elif p_tag == 'before' or p_tag == 'partof': elif p_tag == 'before' or p_tag == 'partof':
self.todolist.add_dependency(dep, self.todo) self.todolist.add_dependency(dep, self.todo)
except ValueError:
continue
except InvalidTodoException: except InvalidTodoException:
pass 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_start())
convert_date(config().tag_due()) 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