Commit d9efdf83 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Allow any tag to have a date value.

Fixes a bug that ListCommand wouldn't show items matching key:2014-12-12
parent d106c563
...@@ -57,7 +57,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -57,7 +57,7 @@ class ListCommandTest(CommandTest.CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEquals(self.output, "| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value id:1\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2 p:1\n") self.assertEquals(self.output, "| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value id:1\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2 p:1\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n")
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list6(self): def test_list6(self):
...@@ -125,7 +125,7 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -125,7 +125,7 @@ class ListCommandTest(CommandTest.CommandTest):
command.execute() command.execute()
self.assertFalse(self.todolist.is_dirty()) self.assertFalse(self.todolist.is_dirty())
self.assertEquals(self.output, "| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value id:1\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n") self.assertEquals(self.output, "| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value id:1\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n")
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list14(self): def test_list14(self):
...@@ -164,6 +164,13 @@ class ListCommandTest(CommandTest.CommandTest): ...@@ -164,6 +164,13 @@ class ListCommandTest(CommandTest.CommandTest):
self.assertEquals(self.output, "| 3| (C) Baz @Context1 +Project1 key:value id:1\n") self.assertEquals(self.output, "| 3| (C) Baz @Context1 +Project1 key:value id:1\n")
self.assertEquals(self.errors, "") self.assertEquals(self.errors, "")
def test_list18(self):
command = ListCommand(["-x", "date:2014-12-12"], self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEquals(self.output, "| 6| x 2014-12-12 Completed but with date:2014-12-12\n")
def test_help(self): def test_help(self):
command = ListCommand(["help"], self.todolist, self.out, self.error) command = ListCommand(["help"], self.todolist, self.out, self.error)
command.execute() command.execute()
......
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
(C) Drink beer @ home (C) Drink beer @ home
(C) 13 + 29 = 42 (C) 13 + 29 = 42
x 2014-12-12 Completed but with date:2014-12-12
...@@ -168,7 +168,7 @@ class OrdinalTagFilter(Filter): ...@@ -168,7 +168,7 @@ class OrdinalTagFilter(Filter):
if not self.key or not p_todo.has_tag(self.key): if not self.key or not p_todo.has_tag(self.key):
return False return False
if self.key == config().tag_due() or self.key == config().tag_start(): try:
operand1 = date_string_to_date(p_todo.tag_value(self.key)) operand1 = date_string_to_date(p_todo.tag_value(self.key))
operand2 = relative_date_to_date(self.value) operand2 = relative_date_to_date(self.value)
...@@ -176,8 +176,8 @@ class OrdinalTagFilter(Filter): ...@@ -176,8 +176,8 @@ class OrdinalTagFilter(Filter):
operand2 = date_string_to_date(self.value) operand2 = date_string_to_date(self.value)
if not operand1 or not operand2: if not operand1 or not operand2:
return False raise ValueError
else: except ValueError:
try: try:
operand1 = int(p_todo.tag_value(self.key)) operand1 = int(p_todo.tag_value(self.key))
operand2 = int(self.value) operand2 = int(self.value)
......
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