Commit c6b5ff49 authored by MinchinWeb's avatar MinchinWeb

Fix PEP8 E501 (selected)

line too long (> 79 characters)
parent 059f5119
......@@ -42,146 +42,188 @@ class AddCommandTest(CommandTest):
def test_add_task(self):
args = ["New todo"]
command = AddCommand.AddCommand(args, self.todolist, self.out, self.error)
command = AddCommand.AddCommand(args, self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " New todo")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " New todo")
self.assertEqual(self.errors, "")
def test_add_multiple_args(self):
args = ["New", "todo"]
command = AddCommand.AddCommand(args, self.todolist, self.out, self.error)
command = AddCommand.AddCommand(args, self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " New todo")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " New todo")
self.assertEqual(self.errors, "")
def test_add_priority1(self):
command = AddCommand.AddCommand(["Foo (C)"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo (C)"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).priority(), 'C')
self.assertEqual(self.todolist.todo(1).source(), "(C) " + self.today + " Foo")
self.assertEqual(self.todolist.todo(1).source(),
"(C) " + self.today + " Foo")
self.assertEqual(self.errors, "")
def test_add_priority2(self):
command = AddCommand.AddCommand(["Foo (CC)"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo (CC)"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).priority(), None)
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo (CC)")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo (CC)")
self.assertEqual(self.errors, "")
def test_add_priority3(self):
command = AddCommand.AddCommand(["Fo(C)o"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Fo(C)o"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).priority(), None)
self.assertEqual(self.todolist.todo(1).source(), self.today + " Fo(C)o")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Fo(C)o")
self.assertEqual(self.errors, "")
def test_add_priority4(self):
command = AddCommand.AddCommand(["(C) Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["(C) Foo"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).priority(), 'C')
self.assertEqual(self.todolist.todo(1).source(), "(C) " + self.today + " Foo")
self.assertEqual(self.todolist.todo(1).source(),
"(C) " + self.today + " Foo")
self.assertEqual(self.errors, "")
def test_add_dep01(self):
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Bar before:1"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar before:1"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(), self.today + " Bar p:1")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(),
self.today + " Bar p:1")
self.assertEqual(self.errors, "")
def test_add_dep02(self):
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Bar partof:1"], self.todolist)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(), self.today + " Bar p:1")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(),
self.today + " Bar p:1")
self.assertEqual(self.errors, "")
def test_add_dep03(self):
command = AddCommand.AddCommand(["Foo"], self.todolist)
command.execute()
command = AddCommand.AddCommand(["Bar after:1"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar after:1"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo p:1")
self.assertEqual(self.todolist.todo(2).source(), self.today + " Bar id:1")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo p:1")
self.assertEqual(self.todolist.todo(2).source(),
self.today + " Bar id:1")
self.assertEqual(self.errors, "")
def test_add_de04(self):
""" Test for using an after: tag with non-existing value. """
command = AddCommand.AddCommand(["Foo after:1"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo after:1"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.todo(1).has_tag("after"))
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo")
self.assertEqual(self.output, "| 1| " + self.todolist.todo(1).source() + "\n")
self.assertEqual(self.output,
"| 1| " + self.todolist.todo(1).source() + "\n")
self.assertEqual(self.errors, "")
def test_add_dep05(self):
""" Test for using an after: tag with non-existing value. """
command = AddCommand.AddCommand(["Foo after:2"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo after:2"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.todo(1).has_tag("after"))
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo")
self.assertEqual(self.output, "| 1| " + self.todolist.todo(1).source() + "\n")
self.assertEqual(self.output,
"| 1| " + self.todolist.todo(1).source() + "\n")
self.assertEqual(self.errors, "")
def test_add_dep06(self):
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Bar"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Baz before:1 before:2"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Baz before:1 before:2"],
self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(), self.today + " Bar id:2")
self.assertEqual(self.todolist.todo(3).source(), self.today + " Baz p:1 p:2")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo id:1")
self.assertEqual(self.todolist.todo(2).source(),
self.today + " Bar id:2")
self.assertEqual(self.todolist.todo(3).source(),
self.today + " Baz p:1 p:2")
self.assertEqual(self.errors, "")
def test_add_dep07(self):
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Bar"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Baz after:1 after:2"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Baz after:1 after:2"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo p:1")
self.assertEqual(self.todolist.todo(2).source(), self.today + " Bar p:1")
self.assertEqual(self.todolist.todo(3).source(), self.today + " Baz id:1")
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo p:1")
self.assertEqual(self.todolist.todo(2).source(),
self.today + " Bar p:1")
self.assertEqual(self.todolist.todo(3).source(),
self.today + " Baz id:1")
self.assertEqual(self.errors, "")
def test_add_dep08(self):
config("test/data/todolist-uid.conf")
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo"], self.todolist, self.out,
self.error)
command.execute()
command = AddCommand.AddCommand(["Bar after:7ui"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar after:7ui"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo('7ui').source(), "{} Foo p:1".format(self.today))
self.assertEqual(self.todolist.todo('8to').source(), "{} Bar id:1".format(self.today))
self.assertEqual(self.todolist.todo('7ui').source(),
"{} Foo p:1".format(self.today))
self.assertEqual(self.todolist.todo('8to').source(),
"{} Bar id:1".format(self.today))
def test_add_dep09(self):
"""
......@@ -192,13 +234,16 @@ class AddCommandTest(CommandTest):
# pass identitiy function to for writing output, we're not interested
# in this output
command = AddCommand.AddCommand(["Foo +Project"], self.todolist, lambda t: t, self.error)
command = AddCommand.AddCommand(["Foo +Project"], self.todolist,
lambda t: t, self.error)
command.execute()
command = AddCommand.AddCommand(["Bar before:kh0"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar before:kh0"], self.todolist,
self.out, self.error)
command.execute()
command = ListCommand.ListCommand(["Bar"], self.todolist, self.out, self.error)
command = ListCommand.ListCommand(["Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "|kbn| {today} Bar p:1 +Project\n|kbn| {today} Bar +Project\n".format(today=self.today))
......@@ -212,49 +257,61 @@ class AddCommandTest(CommandTest):
# pass identitiy function to for writing output, we're not interested
# in this output
command = AddCommand.AddCommand(["Foo @Context"], self.todolist, lambda t: t, self.error)
command = AddCommand.AddCommand(["Foo @Context"], self.todolist,
lambda t: t, self.error)
command.execute()
command = AddCommand.AddCommand(["Bar before:2a2"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Bar before:2a2"], self.todolist,
self.out, self.error)
command.execute()
command = ListCommand.ListCommand(["Bar"], self.todolist, self.out, self.error)
command = ListCommand.ListCommand(["Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "|wb3| {today} Bar p:1 @Context\n|wb3| {today} Bar @Context\n".format(today=self.today))
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()
self.assertEqual(self.todolist.todo(1).source(), self.today + " Foo due:" + self.today)
self.assertEqual(self.todolist.todo(1).source(),
self.today + " Foo due:" + self.today)
self.assertEqual(self.errors, "")
def test_add_reldate2(self):
command = AddCommand.AddCommand(["Foo t:today due:today"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["Foo t:today due:today"],
self.todolist, self.out, self.error)
command.execute()
result = "| 1| {} Foo t:{} due:{}\n".format(self.today, self.today, self.today)
result = "| 1| {} Foo t:{} due:{}\n".format(self.today, self.today,
self.today)
self.assertEqual(self.output, result)
self.assertEqual(self.errors, "")
def test_add_empty(self):
command = AddCommand.AddCommand([], self.todolist, self.out, self.error)
command = AddCommand.AddCommand([], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n")
def test_add_unicode(self):
command = AddCommand.AddCommand([u("Special \u25c4")], self.todolist, self.out, self.error)
command = AddCommand.AddCommand([u("Special \u25c4")], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.output, u("| 1| {} Special \u25c4\n").format(self.today))
self.assertEqual(self.output,
u("| 1| {} Special \u25c4\n").format(self.today))
self.assertEqual(self.errors, "")
@mock.patch("topydo.commands.AddCommand.stdin", StringIO(u("Fo\u00f3 due:tod id:1\nB\u0105r before:1")))
@mock.patch("topydo.commands.AddCommand.stdin",
StringIO(u("Fo\u00f3 due:tod id:1\nB\u0105r before:1")))
def test_add_from_stdin(self):
command = AddCommand.AddCommand(["-f", "-"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["-f", "-"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, u("| 1| {tod} Fo\u00f3 due:{tod} id:1\n| 2| {tod} B\u0105r p:1\n".format(tod=self.today)))
......@@ -271,18 +328,21 @@ class AddCommandTest(CommandTest):
config(p_overrides={('add', 'auto_creation_date'): '0'})
args = ["New todo"]
command = AddCommand.AddCommand(args, self.todolist, self.out, self.error)
command = AddCommand.AddCommand(args, self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), "New todo")
self.assertEqual(self.errors, "")
def test_help(self):
command = AddCommand.AddCommand(["help"], self.todolist, self.out, self.error)
command = AddCommand.AddCommand(["help"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -28,14 +28,16 @@ class AppendCommandTest(CommandTest):
self.todolist.add("Foo")
def test_append1(self):
command = AppendCommand([1, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "| 1| Foo Bar\n")
self.assertEqual(self.errors, "")
def test_append2(self):
command = AppendCommand([2, "Bar"], self.todolist, self.out, self.error)
command = AppendCommand([2, "Bar"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
......@@ -56,7 +58,8 @@ class AppendCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_append5(self):
command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out, self.error)
command = AppendCommand([1, "Bar", "Baz"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "| 1| Foo Bar Baz\n")
......@@ -81,7 +84,8 @@ class AppendCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -45,7 +45,8 @@ class DeleteCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_del1(self):
command = DeleteCommand(["1"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["1"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -54,7 +55,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_del1_regex(self):
command = DeleteCommand(["Foo"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["Foo"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -63,16 +65,19 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_del2(self):
command = DeleteCommand(["1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["1"], self.todolist, self.out, self.error,
_yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.todolist.count(), 2)
self.assertEqual(self.output, "| 2| Bar p:1\nRemoved: Bar\nRemoved: Foo\n")
self.assertEqual(self.output,
"| 2| Bar p:1\nRemoved: Bar\nRemoved: Foo\n")
self.assertEqual(self.errors, "")
def test_del3(self):
command = DeleteCommand(["-f", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["-f", "1"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -81,7 +86,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_del4(self):
command = DeleteCommand(["--force", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["--force", "1"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -128,7 +134,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del1(self):
""" Test deletion of multiple items. """
command = DeleteCommand(["1", "2"], self.todolist, self.out, self.error, _no_prompt)
command = DeleteCommand(["1", "2"], self.todolist, self.out,
self.error, _no_prompt)
command.execute()
result = "a @test with due:2015-06-03\na @test with +project"
......@@ -138,7 +145,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del2(self):
""" Test deletion of multiple items. """
command = DeleteCommand(["1", "2"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["1", "2"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
result = "a @test with due:2015-06-03\na @test with +project"
......@@ -148,7 +156,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del3(self):
""" Fail if any of supplied todo numbers is invalid. """
command = DeleteCommand(["99", "2"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["99", "2"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -157,7 +166,8 @@ class DeleteCommandTest(CommandTest):
def test_multi_del4(self):
""" Check output when all supplied todo numbers are invalid. """
command = DeleteCommand(["99", "A"], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["99", "A"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -165,16 +175,21 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: A.\n")
def test_multi_del5(self):
""" Throw an error with invalid argument containing special characters. """
command = DeleteCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = DeleteCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "")
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
def test_expr_del1(self):
command = DeleteCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
result = "Removed: a @test with due:2015-06-03\nRemoved: a @test with +project\n"
......@@ -185,7 +200,8 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_del2(self):
command = DeleteCommand(["-e", "@test", "due:2015-06-03"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test", "due:2015-06-03"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -193,14 +209,16 @@ class DeleteCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_del3(self):
command = DeleteCommand(["-e", "@test", "due:2015-06-03", "+project"], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", "@test", "due:2015-06-03", "+project"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_del4(self):
""" Remove only relevant todo items. """
command = DeleteCommand(["-e", ""], self.todolist, self.out, self.error, None)
command = DeleteCommand(["-e", ""], self.todolist, self.out,
self.error, None)
command.execute()
result = "Foo"
......@@ -211,7 +229,8 @@ class DeleteCommandTest(CommandTest):
def test_expr_del5(self):
""" Force deleting unrelevant items with additional -x flag. """
command = DeleteCommand(["-xe", ""], self.todolist, self.out, self.error, _yes_prompt)
command = DeleteCommand(["-xe", ""], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -230,7 +249,8 @@ class DeleteCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -36,7 +36,8 @@ class DepCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_add1(self):
command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "to", "4"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -45,7 +46,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add2(self):
command = DepCommand(["add", "1", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "4"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -54,7 +56,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add3(self):
command = DepCommand(["add", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "99", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -62,7 +65,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_add4(self):
command = DepCommand(["add", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["add", "A", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -78,7 +82,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_add6(self):
command = DepCommand(["add", "1", "after", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "after", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -87,7 +92,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add7(self):
command = DepCommand(["add", "1", "before", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "before", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -96,7 +102,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add8(self):
command = DepCommand(["add", "1", "partof", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "1", "partof", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -105,7 +112,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_add9(self):
command = DepCommand(["add", "Foo", "to", "4"], self.todolist, self.out, self.error)
command = DepCommand(["add", "Foo", "to", "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -141,7 +149,8 @@ class DepCommandTest(CommandTest):
self.rm_helper(["del", "1", "3"])
def test_rm3(self):
command = DepCommand(["rm", "99", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "99", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -149,7 +158,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_rm4(self):
command = DepCommand(["rm", "A", "3"], self.todolist, self.out, self.error)
command = DepCommand(["rm", "A", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -165,7 +175,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_ls1(self):
command = DepCommand(["ls", "1", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "1", "to"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -173,7 +184,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_ls2(self):
command = DepCommand(["ls", "99", "to"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "99", "to"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -181,7 +193,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_ls3(self):
command = DepCommand(["ls", "to", "3"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -189,7 +202,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_ls4(self):
command = DepCommand(["ls", "to", "99"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "to", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -213,7 +227,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_ls7(self):
command = DepCommand(["ls", "top", "99"], self.todolist, self.out, self.error)
command = DepCommand(["ls", "top", "99"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -221,7 +236,8 @@ class DepCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def gc_helper(self, p_subcommand):
command = DepCommand([p_subcommand], self.todolist, self.out, self.error)
command = DepCommand([p_subcommand], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -256,7 +272,8 @@ class DepCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -64,7 +64,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_depri4(self):
command = DepriCommand(["1", "Baz"], self.todolist, self.out, self.error)
command = DepriCommand(["1", "Baz"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -74,7 +75,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri1(self):
command = DepriCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
result = "Priority removed.\n| 4| a @test with due:2015-06-03\nPriority removed.\n| 5| a @test with +project p:1\n"
......@@ -84,7 +86,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri2(self):
command = DepriCommand(["-e", "@test", "due:2015-06-03"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test", "due:2015-06-03"],
self.todolist, self.out, self.error, None)
command.execute()
result = "Priority removed.\n| 4| a @test with due:2015-06-03\n"
......@@ -94,21 +97,24 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_depri3(self):
command = DepriCommand(["-e", "@test", "due:2015-06-03", "+project"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "@test", "due:2015-06-03", "+project"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_depri4(self):
""" Don't remove priority from unrelevant todo items. """
command = DepriCommand(["-e", "Bax"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-e", "Bax"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_depri5(self):
""" Force unprioritizing unrelevant items with additional -x flag. """
command = DepriCommand(["-xe", "Bax"], self.todolist, self.out, self.error, None)
command = DepriCommand(["-xe", "Bax"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -124,7 +130,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_invalid2(self):
command = DepriCommand(["99", "1"], self.todolist, self.out, self.error)
command = DepriCommand(["99", "1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -132,7 +139,8 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\n")
def test_invalid3(self):
command = DepriCommand(["99", "FooBar"], self.todolist, self.out, self.error)
command = DepriCommand(["99", "FooBar"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -140,13 +148,17 @@ class DepriCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: FooBar.\n")
def test_invalid4(self):
""" Throw an error with invalid argument containing special characters. """
command = DepriCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = DepriCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertFalse(self.output)
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
def test_empty(self):
command = DepriCommand([], self.todolist, self.out, self.error)
......@@ -161,7 +173,8 @@ class DepriCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -58,17 +58,19 @@ class DoCommandTest(CommandTest):
self.tomorrow = self.tomorrow.isoformat()
def test_do1(self):
command = DoCommand(["3"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["3"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertTrue(self.todolist.todo(3).is_completed())
self.assertEqual(self.output, "Completed: x {} Baz p:1\n".format(
self.today))
self.assertEqual(self.output,
"Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.errors, "")
def test_do_subtasks1(self):
command = DoCommand(["1"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["1"], self.todolist, self.out, self.error,
_yes_prompt)
command.execute()
result = "| 2| Bar p:1\n| 3| Baz p:1\nCompleted: x {today} Bar p:1\nCompleted: x {today} Baz p:1\nCompleted: x {today} Foo id:1\n".format(today=self.today)
......@@ -82,7 +84,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_do_subtasks2(self):
command = DoCommand(["1"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["1"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
result = "| 2| Bar p:1\n| 3| Baz p:1\nCompleted: x {} Foo id:1\n".format(self.today)
......@@ -101,7 +104,8 @@ class DoCommandTest(CommandTest):
global prompt_shown
prompt_shown = True
command = DoCommand(["-f", "1"], self.todolist, self.out, self.error, prompt)
command = DoCommand(["-f", "1"], self.todolist, self.out, self.error,
prompt)
command.execute()
self.assertFalse(prompt_shown)
......@@ -115,7 +119,8 @@ class DoCommandTest(CommandTest):
global prompt_shown
prompt_shown = True
command = DoCommand(["--force", "1"], self.todolist, self.out, self.error, prompt)
command = DoCommand(["--force", "1"], self.todolist, self.out,
self.error, prompt)
command.execute()
self.assertFalse(prompt_shown)
......@@ -171,7 +176,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_invalid3(self):
command = DoCommand(["01"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["01"], self.todolist, self.out, self.error,
_yes_prompt)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -205,7 +211,8 @@ class DoCommandTest(CommandTest):
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.todolist.todo(5).completion_date(), date(2014, 10, 18))
self.assertEqual(self.todolist.todo(5).completion_date(),
date(2014, 10, 18))
self.assertFalse(self.output)
self.assertEqual(self.errors, "Todo has already been completed.\n")
......@@ -215,11 +222,13 @@ class DoCommandTest(CommandTest):
self.assertTrue(self.todolist.is_dirty())
self.assertTrue(self.todolist.todo(3).is_completed())
self.assertEqual(self.output, "Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.output,
"Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.errors, "")
def test_do_custom_date1(self):
command = DoCommand(["-d", "2014-11-18", "3"], self.todolist, self.out, self.error)
command = DoCommand(["-d", "2014-11-18", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -227,7 +236,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_do_custom_date2(self):
command = DoCommand(["-d", "2014-11-18", "1"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["-d", "2014-11-18", "1"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -235,7 +245,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_do_custom_date3(self):
command = DoCommand(["--date=2014-11-18", "3"], self.todolist, self.out, self.error)
command = DoCommand(["--date=2014-11-18", "3"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -243,11 +254,13 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_do_custom_date4(self):
command = DoCommand(["-d", "foo", "3"], self.todolist, self.out, self.error)
command = DoCommand(["-d", "foo", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.output,
"Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.errors, "")
def test_do_custom_date5(self):
......@@ -255,7 +268,8 @@ class DoCommandTest(CommandTest):
Make sure that the new recurrence date is correct when a custom
date is given.
"""
command = DoCommand(["-d", self.yesterday, "4"], self.todolist, self.out, self.error)
command = DoCommand(["-d", self.yesterday, "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -268,7 +282,8 @@ class DoCommandTest(CommandTest):
due date as the offset. This todo item however, has no due date, then
the completion date must be used as an offset.
"""
command = DoCommand(["-s", "-d", self.yesterday, "4"], self.todolist, self.out, self.error)
command = DoCommand(["-s", "-d", self.yesterday, "4"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -280,7 +295,8 @@ class DoCommandTest(CommandTest):
When a custom date is set, strict recurrence must still hold on to the
due date as the offset.
"""
command = DoCommand(["-s", "-d", self.yesterday, "8"], self.todolist, self.out, self.error)
command = DoCommand(["-s", "-d", self.yesterday, "8"], self.todolist,
self.out, self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -288,7 +304,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_multi_do1(self):
command = DoCommand(["1", "3"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["1", "3"], self.todolist, self.out, self.error,
_yes_prompt)
command.execute()
self.assertTrue(self.todolist.todo(1).is_completed())
......@@ -298,7 +315,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.output, "| 2| Bar p:1\n| 3| Baz p:1\nCompleted: x {today} Bar p:1\nCompleted: x {today} Baz p:1\nCompleted: x {today} Foo id:1\n".format(today=self.today))
def test_multi_do2(self):
command = DoCommand(["1", "3"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["1", "3"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.todo(1).is_completed())
......@@ -308,14 +326,17 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.output, "| 2| Bar p:1\n| 3| Baz p:1\nCompleted: x {today} Foo id:1\nCompleted: x {today} Baz p:1\n".format(today=self.today))
def test_multi_do3(self):
command = DoCommand(["3", "3"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["3", "3"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertTrue(self.todolist.todo(3).is_completed())
self.assertEqual(self.output, "Completed: x {} Baz p:1\n".format(self.today))
self.assertEqual(self.output,
"Completed: x {} Baz p:1\n".format(self.today))
def test_multi_do4(self):
command = DoCommand(["99", "3"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["99", "3"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertFalse(self.todolist.todo(3).is_completed())
......@@ -325,21 +346,27 @@ class DoCommandTest(CommandTest):
"""
Check output when all supplied todo numbers are invalid.
"""
command = DoCommand(["99", "15"], self.todolist, self.out, self.error, _no_prompt)
command = DoCommand(["99", "15"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: 15.\n")
def test_multi_do6(self):
""" Throw an error with invalid argument containing special characters. """
command = DoCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = DoCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
def test_expr_do1(self):
command = DoCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = DoCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -347,7 +374,8 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_do2(self):
command = DoCommand(["-e", "@test", "due:2015-06-03"], self.todolist, self.out, self.error, None)
command = DoCommand(["-e", "@test", "due:2015-06-03"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -355,21 +383,24 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_do3(self):
command = DoCommand(["-e", "@test", "due:2015-06-03", "+project"], self.todolist, self.out, self.error, None)
command = DoCommand(["-e", "@test", "due:2015-06-03", "+project"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_do4(self):
""" Don't do anything with unrelevant todo items. """
command = DoCommand(["-e", "Foo"], self.todolist, self.out, self.error, None)
command = DoCommand(["-e", "Foo"], self.todolist, self.out, self.error,
None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_do5(self):
""" Force marking unrelevant items as done with additional -x flag. """
command = DoCommand(["-xe", "Foo"], self.todolist, self.out, self.error, _yes_prompt)
command = DoCommand(["-xe", "Foo"], self.todolist, self.out,
self.error, _yes_prompt)
command.execute()
result = "| 2| Bar p:1\n| 3| Baz p:1\nCompleted: x {t} Bar p:1\nCompleted: x {t} Baz p:1\nCompleted: x {t} Foo id:1\n".format(t=self.today)
......@@ -379,11 +410,15 @@ class DoCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_invalid_recurrence(self):
""" Show error message when an item has an invalid recurrence pattern. """
command = DoCommand(["9"], self.todolist, self.out, self.error, _no_prompt)
"""
Show error message when an item has an invalid recurrence pattern.
"""
command = DoCommand(["9"], self.todolist, self.out, self.error,
_no_prompt)
command.execute()
self.assertEqual(self.output, "Completed: x {} Invalid rec:1\n".format(self.today))
self.assertEqual(self.output,
"Completed: x {} Invalid rec:1\n".format(self.today))
self.assertEqual(self.errors, "Warning: todo item has an invalid recurrence pattern.\n")
def test_empty(self):
......@@ -399,7 +434,8 @@ class DoCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -64,7 +64,8 @@ class EditCommandTest(CommandTest):
mock_open_in_editor.return_value = 0
mock_todos_from_temp.return_value = [Todo('Lazy Cat')]
command = EditCommand(["Bar"], self.todolist, self.out, self.error, None)
command = EditCommand(["Bar"], self.todolist, self.out, self.error,
None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -73,7 +74,8 @@ class EditCommandTest(CommandTest):
def test_edit3(self):
""" Throw an error after invalid todo number given as argument. """
command = EditCommand(["FooBar"], self.todolist, self.out, self.error, None)
command = EditCommand(["FooBar"], self.todolist, self.out, self.error,
None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -81,7 +83,8 @@ class EditCommandTest(CommandTest):
def test_edit4(self):
""" Throw an error with pointing invalid argument. """
command = EditCommand(["Bar", "5"], self.todolist, self.out, self.error, None)
command = EditCommand(["Bar", "5"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -94,7 +97,8 @@ class EditCommandTest(CommandTest):
mock_open_in_editor.return_value = 0
mock_todos_from_temp.return_value = [Todo('Only one line')]
command = EditCommand(["1", "Bar"], self.todolist, self.out, self.error, None)
command = EditCommand(["1", "Bar"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -102,12 +106,16 @@ class EditCommandTest(CommandTest):
self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a"))
def test_edit6(self):
""" Throw an error with invalid argument containing special characters. """
command = EditCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = EditCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
@mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
......@@ -116,21 +124,25 @@ class EditCommandTest(CommandTest):
mock_open_in_editor.return_value = 0
mock_todos_from_temp.return_value = [Todo('Lazy Cat')]
command = EditCommand([u("Fo\u00f3B\u0105\u017a")], self.todolist, self.out, self.error, None)
command = EditCommand([u("Fo\u00f3B\u0105\u017a")], self.todolist,
self.out, self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.errors, "")
self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat"))
self.assertEqual(self.todolist.print_todos(),
u("Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat"))
@mock.patch('topydo.commands.EditCommand.EditCommand._todos_from_temp')
@mock.patch('topydo.commands.EditCommand.EditCommand._open_in_editor')
def test_edit_expr(self, mock_open_in_editor, mock_todos_from_temp):
""" Edit todos matching expression. """
mock_open_in_editor.return_value = 0
mock_todos_from_temp.return_value = [Todo('Lazy Cat'), Todo('Lazy Dog')]
mock_todos_from_temp.return_value = [Todo('Lazy Cat'),
Todo('Lazy Dog')]
command = EditCommand(["-e", "@test"], self.todolist, self.out, self.error, None)
command = EditCommand(["-e", "@test"], self.todolist, self.out,
self.error, None)
command.execute()
expected = u("| 3| Lazy Cat\n| 4| Lazy Dog\n")
......@@ -149,7 +161,8 @@ class EditCommandTest(CommandTest):
os.environ['EDITOR'] = editor
archive = config().archive()
command = EditCommand(["-d"], self.todolist, self.out, self.error, None)
command = EditCommand(["-d"], self.todolist, self.out, self.error,
None)
command.execute()
self.assertEqual(self.errors, "")
......
......@@ -132,7 +132,8 @@ class FilterTest(TopydoTest):
filtered_todos = limit_filter.filter(todos)
self.assertEqual(len(filtered_todos), 1)
self.assertEqual(filtered_todos[0].source(), '(C) This is part of some +Project')
self.assertEqual(filtered_todos[0].source(),
'(C) This is part of some +Project')
def test_filter14(self):
""" Test limit filter. """
......
......@@ -64,7 +64,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.incoming_neighbors(1, True), set())
def test_incoming_neighbors4(self):
self.assertEqual(self.graph.incoming_neighbors(5, True), set([1, 2, 3, 4, 6]))
self.assertEqual(self.graph.incoming_neighbors(5, True),
set([1, 2, 3, 4, 6]))
def test_outgoing_neighbors1(self):
self.assertEqual(self.graph.outgoing_neighbors(1), set([2, 3]))
......@@ -73,7 +74,8 @@ class GraphTest(TopydoTest):
self.assertEqual(self.graph.outgoing_neighbors(2), set([4]))
def test_outgoing_neighbors3(self):
self.assertEqual(self.graph.outgoing_neighbors(1, True), set([2, 3, 4, 5, 6]))
self.assertEqual(self.graph.outgoing_neighbors(1, True),
set([2, 3, 4, 5, 6]))
def test_outgoing_neighbors4(self):
self.assertEqual(self.graph.outgoing_neighbors(3), set([5]))
......
......@@ -39,7 +39,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list03(self):
command = ListCommand(["Context1"], self.todolist, self.out, self.error)
command = ListCommand(["Context1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -47,7 +48,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list04(self):
command = ListCommand(["-x", "Context1"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "Context1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -63,7 +65,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list06(self):
command = ListCommand(["Project3"], self.todolist, self.out, self.error)
command = ListCommand(["Project3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -71,7 +74,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list07(self):
command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist, self.out, self.error)
command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -79,7 +83,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list08(self):
command = ListCommand(["--", "-project1"], self.todolist, self.out, self.error)
command = ListCommand(["--", "-project1"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -87,7 +92,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list09(self):
command = ListCommand(["--", "-project1", "-Drink"], self.todolist, self.out, self.error)
command = ListCommand(["--", "-project1", "-Drink"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -95,7 +101,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list10(self):
command = ListCommand(["text1", "2"], self.todolist, self.out, self.error)
command = ListCommand(["text1", "2"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -115,7 +122,8 @@ class ListCommandTest(CommandTest):
def test_list12(self):
config("test/data/listcommand.conf")
command = ListCommand(["-x", "project"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "project"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -123,7 +131,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list13(self):
command = ListCommand(["-x", "--", "-@Context1 +Project2"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "--", "-@Context1 +Project2"],
self.todolist, self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -159,15 +168,18 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list17(self):
command = ListCommand(["-x", "id:"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "id:"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "| 3| (C) Baz @Context1 +Project1 key:value\n")
self.assertEqual(self.output,
"| 3| (C) Baz @Context1 +Project1 key:value\n")
self.assertEqual(self.errors, "")
def test_list18(self):
command = ListCommand(["-x", "date:2014-12-12"], self.todolist, self.out, self.error)
command = ListCommand(["-x", "date:2014-12-12"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -177,7 +189,8 @@ class ListCommandTest(CommandTest):
""" Force showing all tags. """
config('test/data/listcommand-tags.conf')
command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist, self.out, self.error)
command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -193,7 +206,8 @@ class ListCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_list21(self):
command = ListCommand(["-f invalid"], self.todolist, self.out, self.error)
command = ListCommand(["-f invalid"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -216,7 +230,8 @@ class ListCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
class ListCommandUnicodeTest(CommandTest):
......@@ -226,7 +241,8 @@ class ListCommandUnicodeTest(CommandTest):
def test_list_unicode1(self):
""" Unicode filters """
command = ListCommand([u("\u25c4")], self.todolist, self.out, self.error)
command = ListCommand([u("\u25c4")], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -246,7 +262,8 @@ class ListCommandJsonTest(CommandTest):
self.assertFalse(todolist.is_dirty())
jsontext = ""
with codecs.open('test/data/ListCommandTest.json', 'r', encoding='utf-8') as json:
with codecs.open('test/data/ListCommandTest.json', 'r',
encoding='utf-8') as json:
jsontext = json.read()
self.assertEqual(self.output, jsontext)
......@@ -261,7 +278,8 @@ class ListCommandJsonTest(CommandTest):
self.assertFalse(todolist.is_dirty())
jsontext = ""
with codecs.open('test/data/ListCommandUnicodeTest.json', 'r', encoding='utf-8') as json:
with codecs.open('test/data/ListCommandUnicodeTest.json', 'r',
encoding='utf-8') as json:
jsontext = json.read()
self.assertEqual(self.output, jsontext)
......@@ -283,16 +301,19 @@ class ListCommandIcalTest(CommandTest):
def test_ical(self):
todolist = load_file_to_todolist("test/data/ListCommandIcalTest.txt")
command = ListCommand(["-x", "-f", "ical"], todolist, self.out, self.error)
command = ListCommand(["-x", "-f", "ical"], todolist, self.out,
self.error)
command.execute()
self.assertTrue(todolist.is_dirty())
icaltext = ""
with codecs.open('test/data/ListCommandTest.ics', 'r', encoding='utf-8') as ical:
with codecs.open('test/data/ListCommandTest.ics', 'r',
encoding='utf-8') as ical:
icaltext = ical.read()
self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext))
self.assertEqual(replace_ical_tags(self.output),
replace_ical_tags(icaltext))
self.assertEqual(self.errors, "")
def test_ical_unicode(self):
......@@ -304,10 +325,12 @@ class ListCommandIcalTest(CommandTest):
self.assertTrue(todolist.is_dirty())
icaltext = ""
with codecs.open('test/data/ListCommandUnicodeTest.ics', 'r', encoding='utf-8') as ical:
with codecs.open('test/data/ListCommandUnicodeTest.ics', 'r',
encoding='utf-8') as ical:
icaltext = ical.read()
self.assertEqual(replace_ical_tags(self.output), replace_ical_tags(icaltext))
self.assertEqual(replace_ical_tags(self.output),
replace_ical_tags(icaltext))
self.assertEqual(self.errors, "")
if __name__ == '__main__':
......
......@@ -43,7 +43,8 @@ class ListContextCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -43,7 +43,8 @@ class ListProjectCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -44,37 +44,44 @@ class PostponeCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_postpone01(self):
command = PostponeCommand(["1", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 1| Foo due:{}\n".format(due.isoformat()))
self.assertEqual(self.output,
"| 1| Foo due:{}\n".format(due.isoformat()))
self.assertEqual(self.errors, "")
def test_postpone02(self):
command = PostponeCommand(["2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["2", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 2| Bar due:{}\n".format(due.isoformat()))
self.assertEqual(self.output,
"| 2| Bar due:{}\n".format(due.isoformat()))
self.assertEqual(self.errors, "")
def test_postpone03(self):
command = PostponeCommand(["-s", "2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "2", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 2| Bar due:{}\n".format(due.isoformat()))
self.assertEqual(self.output,
"| 2| Bar due:{}\n".format(due.isoformat()))
self.assertEqual(self.errors, "")
def test_postpone04(self):
command = PostponeCommand(["3", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["3", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -84,7 +91,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone05(self):
command = PostponeCommand(["-s", "3", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "3", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -96,17 +104,20 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone06(self):
command = PostponeCommand(["4", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["4", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 4| Past due:{}\n".format(due.isoformat()))
self.assertEqual(self.output,
"| 4| Past due:{}\n".format(due.isoformat()))
self.assertEqual(self.errors, "")
def test_postpone07(self):
command = PostponeCommand(["5", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["5", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.future + timedelta(7)
......@@ -117,7 +128,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone08(self):
command = PostponeCommand(["-s", "5", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "5", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.future + timedelta(7)
......@@ -129,7 +141,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone09(self):
command = PostponeCommand(["1", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "foo"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -137,7 +150,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid date pattern given.\n")
def test_postpone10(self):
command = PostponeCommand(["99", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["99", "foo"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -145,7 +159,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_postpone11(self):
command = PostponeCommand(["A", "foo"], self.todolist, self.out, self.error)
command = PostponeCommand(["A", "foo"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -161,17 +176,20 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_postpone13(self):
command = PostponeCommand(["Foo", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["Foo", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 1| Foo due:{}\n".format(due.isoformat()))
self.assertEqual(self.output,
"| 1| Foo due:{}\n".format(due.isoformat()))
self.assertEqual(self.errors, "")
def test_postpone14(self):
command = PostponeCommand(["1", "2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "2", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -181,7 +199,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone15(self):
command = PostponeCommand(["Foo", "2", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["Foo", "2", "1w"], self.todolist, self.out,
self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -191,7 +210,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone16(self):
command = PostponeCommand(["-s", "2", "3", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["-s", "2", "3", "1w"], self.todolist,
self.out, self.error)
command.execute()
due = self.today + timedelta(7)
......@@ -203,7 +223,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_postpone17(self):
command = PostponeCommand(["1", "2", "3"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "2", "3"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -211,7 +232,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid date pattern given.\n")
def test_postpone18(self):
command = PostponeCommand(["1", "99", "123", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["1", "99", "123", "1w"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -219,7 +241,8 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\nInvalid todo number given: 123.\n")
def test_postpone19(self):
command = PostponeCommand(["Zoo", "99", "123", "1w"], self.todolist, self.out, self.error)
command = PostponeCommand(["Zoo", "99", "123", "1w"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -228,15 +251,18 @@ class PostponeCommandTest(CommandTest):
def test_postpone20(self):
""" Throw an error with invalid argument containing special characters. """
command = PostponeCommand([u("Fo\u00d3B\u0105r"), "Bar", "1d"], self.todolist, self.out, self.error, None)
command = PostponeCommand([u("Fo\u00d3B\u0105r"), "Bar", "1d"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "")
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
def test_expr_postpone1(self):
command = PostponeCommand(["-e", "due:tod", "2w"], self.todolist, self.out, self.error, None)
command = PostponeCommand(["-e", "due:tod", "2w"], self.todolist,
self.out, self.error, None)
command.execute()
due = self.today + timedelta(14)
......@@ -248,33 +274,38 @@ class PostponeCommandTest(CommandTest):
def test_expr_postpone2(self):
cmd_args = ["-e", "t:{}".format(self.start.isoformat()), "due:tod", "1w"]
command = PostponeCommand(cmd_args, self.todolist, self.out, self.error, None)
command = PostponeCommand(cmd_args, self.todolist, self.out,
self.error, None)
command.execute()
due = self.today + timedelta(7)
result = "| 3| Baz due:{} t:{}\n".format(due.isoformat(), self.start.isoformat())
result = "| 3| Baz due:{} t:{}\n".format(due.isoformat(),
self.start.isoformat())
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, result)
self.assertEqual(self.errors, "")
def test_expr_postpone3(self):
command = PostponeCommand(["-e", "@test", "due:tod", "+project", "C"], self.todolist, self.out, self.error, None)
command = PostponeCommand(["-e", "@test", "due:tod", "+project", "C"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_postpone4(self):
""" Don't postpone unrelevant todo items. """
command = PostponeCommand(["-e", "FutureStart", "1w"], self.todolist, self.out, self.error, None)
command = PostponeCommand(["-e", "FutureStart", "1w"], self.todolist,
self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_postpone5(self):
""" Force postponing unrelevant items with additional -x flag. """
command = PostponeCommand(["-xe", "FutureStart", "1w"], self.todolist, self.out, self.error, None)
command = PostponeCommand(["-xe", "FutureStart", "1w"], self.todolist,
self.out, self.error, None)
command.execute()
due = self.today + timedelta(7)
......@@ -285,11 +316,13 @@ class PostponeCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_help(self):
command = PostponeCommand(["help"], self.todolist, self.out, self.error)
command = PostponeCommand(["help"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -36,15 +36,18 @@ class PriorityCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_set_prio1(self):
command = PriorityCommand(["1", "B"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "B"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Priority changed from A to B\n| 1| (B) Foo\n")
self.assertEqual(self.output,
"Priority changed from A to B\n| 1| (B) Foo\n")
self.assertEqual(self.errors, "")
def test_set_prio2(self):
command = PriorityCommand(["2", "Z"], self.todolist, self.out, self.error)
command = PriorityCommand(["2", "Z"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -52,15 +55,18 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_prio3(self):
command = PriorityCommand(["Foo", "B"], self.todolist, self.out, self.error)
command = PriorityCommand(["Foo", "B"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Priority changed from A to B\n| 1| (B) Foo\n")
self.assertEqual(self.output,
"Priority changed from A to B\n| 1| (B) Foo\n")
self.assertEqual(self.errors, "")
def test_set_prio4(self):
command = PriorityCommand(["1", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "A"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -68,7 +74,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_prio5(self):
command = PriorityCommand(["Foo", "2", "C"], self.todolist, self.out, self.error)
command = PriorityCommand(["Foo", "2", "C"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -77,7 +84,8 @@ class PriorityCommandTest(CommandTest):
def test_set_prio6(self):
""" Allow priority to be set including parentheses. """
command = PriorityCommand(["Foo", "2", "(C)"], self.todolist, self.out, self.error)
command = PriorityCommand(["Foo", "2", "(C)"], self.todolist, self.out,
self.error)
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -85,7 +93,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_prio1(self):
command = PriorityCommand(["-e", "@test", "C"], self.todolist, self.out, self.error, None)
command = PriorityCommand(["-e", "@test", "C"], self.todolist,
self.out, self.error, None)
command.execute()
result = "Priority changed from B to C\n| 3| (C) a @test with due:2015-06-03\nPriority set to C.\n| 4| (C) a @test with +project p:1\n"
......@@ -95,7 +104,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_prio2(self):
command = PriorityCommand(["-e", "@test", "due:2015-06-03", "C"], self.todolist, self.out, self.error, None)
command = PriorityCommand(["-e", "@test", "due:2015-06-03", "C"],
self.todolist, self.out, self.error, None)
command.execute()
result = "Priority changed from B to C\n| 3| (C) a @test with due:2015-06-03\n"
......@@ -105,29 +115,35 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_expr_prio3(self):
command = PriorityCommand(["-e", "@test", "due:2015-06-03", "+project", "C"], self.todolist, self.out, self.error, None)
command = PriorityCommand(["-e", "@test", "due:2015-06-03", "+project",
"C"], self.todolist, self.out, self.error,
None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_prio4(self):
""" Don't prioritize unrelevant todo items. """
command = PriorityCommand(["-e", "Baz", "C"], self.todolist, self.out, self.error, None)
command = PriorityCommand(["-e", "Baz", "C"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
def test_expr_prio5(self):
""" Force prioritizing unrelevant items with additional -x flag. """
command = PriorityCommand(["-xe", "Baz", "D"], self.todolist, self.out, self.error, None)
command = PriorityCommand(["-xe", "Baz", "D"], self.todolist, self.out,
self.error, None)
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "Priority set to D.\n| 5| (D) Baz id:1\n")
self.assertEqual(self.output,
"Priority set to D.\n| 5| (D) Baz id:1\n")
self.assertEqual(self.errors, "")
def test_invalid1(self):
command = PriorityCommand(["99", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["99", "A"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -135,7 +151,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given.\n")
def test_invalid2(self):
command = PriorityCommand(["1", "99", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "99", "A"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -143,7 +160,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 99.\n")
def test_invalid3(self):
command = PriorityCommand(["98", "99", "A"], self.todolist, self.out, self.error)
command = PriorityCommand(["98", "99", "A"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -151,7 +169,8 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number given: 98.\nInvalid todo number given: 99.\n")
def test_invalid4(self):
command = PriorityCommand(["1", "ZZ"], self.todolist, self.out, self.error)
command = PriorityCommand(["1", "ZZ"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -175,20 +194,25 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_invalid7(self):
""" Throw an error with invalid argument containing special characters. """
command = PriorityCommand([u("Fo\u00d3B\u0105r"), "Bar", "C"], self.todolist, self.out, self.error, None)
"""
Throw an error with invalid argument containing special characters.
"""
command = PriorityCommand([u("Fo\u00d3B\u0105r"), "Bar", "C"],
self.todolist, self.out, self.error, None)
command.execute()
self.assertFalse(self.todolist.is_dirty())
self.assertEqual(self.output, "")
self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
self.assertEqual(self.errors,
u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
def test_invalid8(self):
"""
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command = PriorityCommand(["2", "(Aa)"], self.todolist, self.out, self.error)
command = PriorityCommand(["2", "(Aa)"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -200,7 +224,8 @@ class PriorityCommandTest(CommandTest):
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command = PriorityCommand(["2", "Aa"], self.todolist, self.out, self.error)
command = PriorityCommand(["2", "Aa"], self.todolist, self.out,
self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -216,11 +241,13 @@ class PriorityCommandTest(CommandTest):
self.assertEqual(self.errors, command.usage() + "\n")
def test_help(self):
command = PriorityCommand(["help"], self.todolist, self.out, self.error)
command = PriorityCommand(["help"], self.todolist, self.out,
self.error)
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -165,12 +165,14 @@ class RecurrenceTest(TopydoTest):
def test_no_recurrence(self):
self.todo.remove_tag('rec')
self.assertRaises(NoRecurrenceException, advance_recurring_todo, self.todo)
self.assertRaises(NoRecurrenceException, advance_recurring_todo,
self.todo)
def test_invalid_recurrence(self):
""" Throw exception when 'rec' tag has an invalid value. """
self.todo.set_tag('rec', '1')
self.assertRaises(NoRecurrenceException, advance_recurring_todo, self.todo)
self.assertRaises(NoRecurrenceException, advance_recurring_todo,
self.todo)
if __name__ == '__main__':
unittest.main()
......@@ -32,13 +32,15 @@ class SortCommandTest(CommandTest):
command = SortCommand(["text"], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.print_todos(), "First\n(A) Foo\n2014-06-14 Last")
self.assertEqual(self.todolist.print_todos(),
"First\n(A) Foo\n2014-06-14 Last")
def test_sort2(self):
command = SortCommand([], self.todolist, self.out, self.error)
command.execute()
self.assertEqual(self.todolist.print_todos(), "(A) Foo\n2014-06-14 Last\nFirst")
self.assertEqual(self.todolist.print_todos(),
"(A) Foo\n2014-06-14 Last\nFirst")
def test_sort3(self):
""" Check that order does not influence the UID of a todo. """
......@@ -56,7 +58,8 @@ class SortCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -40,21 +40,24 @@ class SorterTest(TopydoTest):
def test_sort01(self):
""" Alphabetically sorted """
sorter = Sorter('text')
self.sort_file('test/data/SorterTest1.txt', 'test/data/SorterTest1-result.txt', sorter)
self.sort_file('test/data/SorterTest1.txt',
'test/data/SorterTest1-result.txt', sorter)
def test_sort02a(self):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter = Sorter('prio')
self.sort_file('test/data/SorterTest2.txt', 'test/data/SorterTest2-result.txt', sorter)
self.sort_file('test/data/SorterTest2.txt',
'test/data/SorterTest2-result.txt', sorter)
def test_sort02b(self):
"""
Ascendingly sorted by priority. Also checks stableness of the sort.
"""
sorter = Sorter('asc:prio')
self.sort_file('test/data/SorterTest2.txt', 'test/data/SorterTest2-result.txt', sorter)
self.sort_file('test/data/SorterTest2.txt',
'test/data/SorterTest2-result.txt', sorter)
def test_sort03(self):
"""
......@@ -62,32 +65,38 @@ class SorterTest(TopydoTest):
sort.
"""
sorter = Sorter('desc:prio')
self.sort_file('test/data/SorterTest3.txt', 'test/data/SorterTest3-result.txt', sorter)
self.sort_file('test/data/SorterTest3.txt',
'test/data/SorterTest3-result.txt', sorter)
def test_sort04(self):
""" Ascendingly sorted by due date """
sorter = Sorter(config().tag_due())
self.sort_file('test/data/SorterTest4.txt', 'test/data/SorterTest4-result.txt', sorter)
self.sort_file('test/data/SorterTest4.txt',
'test/data/SorterTest4-result.txt', sorter)
def test_sort05(self):
""" Descendingly sorted by due date """
sorter = Sorter('desc:due')
self.sort_file('test/data/SorterTest5.txt', 'test/data/SorterTest5-result.txt', sorter)
self.sort_file('test/data/SorterTest5.txt',
'test/data/SorterTest5-result.txt', sorter)
def test_sort06(self):
""" Ascendingly sorted by creation date """
sorter = Sorter('creation')
self.sort_file('test/data/SorterTest6.txt', 'test/data/SorterTest6-result.txt', sorter)
self.sort_file('test/data/SorterTest6.txt',
'test/data/SorterTest6-result.txt', sorter)
def test_sort07(self):
""" Ascendingly sorted by completion date. """
sorter = Sorter('completion')
self.sort_file('test/data/SorterTest7.txt', 'test/data/SorterTest7-result.txt', sorter)
self.sort_file('test/data/SorterTest7.txt',
'test/data/SorterTest7-result.txt', sorter)
def test_sort08(self):
""" Descendingly sorted by importance """
sorter = Sorter('desc:importance')
self.sort_file('test/data/SorterTest8.txt', 'test/data/SorterTest8-result.txt', sorter)
self.sort_file('test/data/SorterTest8.txt',
'test/data/SorterTest8-result.txt', sorter)
def test_sort09(self):
"""
......@@ -95,22 +104,26 @@ class SorterTest(TopydoTest):
ascending priority.
"""
sorter = Sorter('desc:importance,priority')
self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
self.sort_file('test/data/SorterTest9.txt',
'test/data/SorterTest9-result.txt', sorter)
def test_sort10(self):
""" Deal with garbage input. """
sorter = Sorter('')
self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9.txt', sorter)
self.sort_file('test/data/SorterTest9.txt',
'test/data/SorterTest9.txt', sorter)
def test_sort11(self):
""" Deal with garbage input. """
sorter = Sorter('fnord')
self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9.txt', sorter)
self.sort_file('test/data/SorterTest9.txt',
'test/data/SorterTest9.txt', sorter)
def test_sort12(self):
""" Deal with garbage input. """
sorter = Sorter('desc:importance,,priority')
self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
self.sort_file('test/data/SorterTest9.txt',
'test/data/SorterTest9-result.txt', sorter)
def test_sort13(self):
"""
......@@ -120,7 +133,8 @@ class SorterTest(TopydoTest):
dependencies the average importance should be equal.
"""
sorter = Sorter('desc:importance-avg')
self.sort_file('test/data/SorterTest9.txt', 'test/data/SorterTest9-result.txt', sorter)
self.sort_file('test/data/SorterTest9.txt',
'test/data/SorterTest9-result.txt', sorter)
def test_sort14(self):
sorter = Sorter('desc:importance-average')
......
......@@ -34,7 +34,8 @@ class TagCommandTest(CommandTest):
self.todolist = TodoList(todos)
def test_add_tag1(self):
command = TagCommand(["1", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["1", "due", "2014-10-22"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), "Foo due:2014-10-22")
......@@ -43,7 +44,8 @@ class TagCommandTest(CommandTest):
self.assertTrue(self.todolist.is_dirty())
def test_add_tag2(self):
command = TagCommand(["Foo", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["Foo", "due", "2014-10-22"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(1).source(), "Foo due:2014-10-22")
......@@ -52,16 +54,20 @@ class TagCommandTest(CommandTest):
self.assertTrue(self.todolist.is_dirty())
def test_add_tag3(self):
command = TagCommand(["-a", "2", "due", "2014-10-19"], self.todolist, self.out, self.error)
command = TagCommand(["-a", "2", "due", "2014-10-19"], self.todolist,
self.out, self.error)
command.execute()
self.assertEqual(self.todolist.todo(2).source(), "Bar due:2014-10-22 due:2014-10-19")
self.assertEqual(self.output, "| 2| Bar due:2014-10-22 due:2014-10-19\n")
self.assertEqual(self.todolist.todo(2).source(),
"Bar due:2014-10-22 due:2014-10-19")
self.assertEqual(self.output,
"| 2| Bar due:2014-10-22 due:2014-10-19\n")
self.assertEqual(self.errors, "")
self.assertTrue(self.todolist.is_dirty())
def test_add_tag4(self):
command = TagCommand(["Foox", "due", "2014-10-22"], self.todolist, self.out, self.error)
command = TagCommand(["Foox", "due", "2014-10-22"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -69,7 +75,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number.\n")
def test_set_tag04(self):
command = TagCommand(["3", "due", "2014-10-20"], self.todolist, self.out, self.error)
command = TagCommand(["3", "due", "2014-10-20"], self.todolist,
self.out, self.error)
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -77,7 +84,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag05(self):
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "all")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "all")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -85,7 +93,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag06(self):
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "1")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "1")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -93,7 +102,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag07(self):
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "2")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "2")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -101,7 +111,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag08(self):
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -109,7 +120,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag09(self):
command = TagCommand(["4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "99")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -117,11 +129,13 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_set_tag10(self):
command = TagCommand(["-f", "4", "due", "2014-10-20"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["-f", "4", "due", "2014-10-20"], self.todolist,
self.out, self.error, lambda t: "99")
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, "| 4| Fnord due:2014-10-20 due:2014-10-20\n")
self.assertEqual(self.output,
"| 4| Fnord due:2014-10-20 due:2014-10-20\n")
self.assertEqual(self.errors, "")
def test_rm_tag01(self):
......@@ -141,15 +155,18 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_rm_tag03(self):
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "all")
command = TagCommand(["4", "due"], self.todolist, self.out,
self.error, lambda t: "all")
command.execute()
self.assertTrue(self.todolist.is_dirty())
self.assertEqual(self.output, " 1. 2014-10-20\n 2. 2014-10-22\n| 4| Fnord\n")
self.assertEqual(self.output,
" 1. 2014-10-20\n 2. 2014-10-22\n| 4| Fnord\n")
self.assertEqual(self.errors, "")
def test_rm_tag04(self):
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "1")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error,
lambda t: "1")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -157,7 +174,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_rm_tag06(self):
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "99")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error,
lambda t: "99")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -165,7 +183,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "")
def test_rm_tag07(self):
command = TagCommand(["4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command = TagCommand(["4", "due"], self.todolist, self.out, self.error,
lambda t: "A")
command.execute()
self.assertFalse(self.todolist.is_dirty())
......@@ -189,7 +208,8 @@ class TagCommandTest(CommandTest):
self.assertEqual(self.errors, "Invalid todo number.\n")
def test_rm_tag10(self):
command = TagCommand(["-f", "4", "due"], self.todolist, self.out, self.error, lambda t: "A")
command = TagCommand(["-f", "4", "due"], self.todolist, self.out,
self.error, lambda t: "A")
command.execute()
self.assertTrue(self.todolist.is_dirty())
......@@ -209,7 +229,8 @@ class TagCommandTest(CommandTest):
command.execute()
self.assertEqual(self.output, "")
self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
self.assertEqual(self.errors,
command.usage() + "\n\n" + command.help() + "\n")
if __name__ == '__main__':
unittest.main()
......@@ -98,7 +98,8 @@ class TodoBaseTester(TopydoTest):
todo.set_tag('foo', 'blah')
self.assertTrue(todo.has_tag('foo', 'blah'))
self.assertTrue(todo.has_tag('foo', 'bar') or todo.has_tag('foo', 'baz'))
self.assertTrue(todo.has_tag('foo', 'bar') or
todo.has_tag('foo', 'baz'))
def test_set_tag_empty_value(self):
todo = TodoBase("(C) Foo foo:bar foo:baz")
......@@ -281,7 +282,8 @@ class TodoBaseTester(TopydoTest):
today_str = today.isoformat()
self.assertEqual(todo.fields['completionDate'], today)
self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo', todo.src))
self.assertTrue(re.match('^x ' + today_str + ' 2014-06-12 Foo',
todo.src))
def test_set_complete5(self):
todo = TodoBase("x 2014-06-13 Foo")
......
......@@ -30,7 +30,8 @@ class TodoFileTest(TopydoTest):
def test_utf_8(self):
todofile = load_file('test/data/utf-8.txt')
self.assertEqual(todofile[0].source(), u('(C) \u25ba UTF-8 test \u25c4'))
self.assertEqual(todofile[0].source(),
u('(C) \u25ba UTF-8 test \u25c4'))
if __name__ == '__main__':
unittest.main()
......@@ -71,7 +71,8 @@ class TodoListTester(TopydoTest):
self.todolist.add('\n(C) New task')
self.assertEqual(self.todolist.count(), count + 1)
self.assertEqual(self.todolist.todo(count + 1).source(), '(C) New task')
self.assertEqual(self.todolist.todo(count + 1).source(),
'(C) New task')
self.assertEqual(self.todolist.todo(count + 1).priority(), 'C')
def test_add3b(self):
......@@ -79,7 +80,8 @@ class TodoListTester(TopydoTest):
self.todolist.add('(C) New task\n')
self.assertEqual(self.todolist.count(), count + 1)
self.assertEqual(self.todolist.todo(count + 1).source(), '(C) New task')
self.assertEqual(self.todolist.todo(count + 1).source(),
'(C) New task')
self.assertEqual(self.todolist.todo(count + 1).priority(), 'C')
def test_add4(self):
......@@ -142,7 +144,8 @@ class TodoListTester(TopydoTest):
def test_todo(self):
count = self.todolist.count()
self.assertRaises(InvalidTodoException, self.todolist.todo, count + 100)
self.assertRaises(InvalidTodoException, self.todolist.todo,
count + 100)
self.assertFalse(self.todolist.is_dirty())
def test_count(self):
......@@ -198,7 +201,8 @@ class TodoListTester(TopydoTest):
def test_uid1(self):
config("test/data/todolist-uid.conf")
self.assertEqual(self.todolist.todo('t5c').source(), "(C) Foo @Context2 Not@Context +Project1 Not+Project")
self.assertEqual(self.todolist.todo('t5c').source(),
"(C) Foo @Context2 Not@Context +Project1 Not+Project")
def test_uid2(self):
""" Changing the priority should not change the identifier. """
......@@ -206,7 +210,8 @@ class TodoListTester(TopydoTest):
todo = self.todolist.todo('t5c')
self.todolist.set_priority(todo, 'B')
self.assertEqual(self.todolist.todo('t5c').source(), "(B) Foo @Context2 Not@Context +Project1 Not+Project")
self.assertEqual(self.todolist.todo('t5c').source(),
"(B) Foo @Context2 Not@Context +Project1 Not+Project")
def test_uid3(self):
"""
......
......@@ -109,7 +109,8 @@ class TopydoCompleter(Completer):
def get_completions(self, p_document, _):
# include all characters except whitespaces (for + and @)
word_before_cursor = p_document.get_word_before_cursor(True)
is_first_word = not re.match(r'\s*\S+\s', p_document.current_line_before_cursor)
is_first_word = not re.match(r'\s*\S+\s',
p_document.current_line_before_cursor)
if is_first_word:
return _subcommands(word_before_cursor)
......
......@@ -65,7 +65,8 @@ class AddCommand(Command):
It detects a priority mid-sentence and puts it at the start.
"""
todo_text = re.sub(r'^(.+) (\([A-Z]\))(.*)$', r'\2 \1\3', p_todo_text)
todo_text = re.sub(r'^(.+) (\([A-Z]\))(.*)$', r'\2 \1\3',
p_todo_text)
return todo_text
......
......@@ -85,8 +85,8 @@ Synopsis: postpone [-s] <NUMBER> [<NUMBER2> ...] <PATTERN>"
return """\
Postpone the todo item(s) with the given number(s) and the given pattern.
Postponing is done by adjusting the due date(s) of the todo(s), and if the -s flag is
given, the start date accordingly.
Postponing is done by adjusting the due date(s) of the todo(s), and if the -s
flag is given, the start date accordingly.
It is also possible to postpone items as complete with an expression using
the -e flag. Use -x to also process todo items that are normally invisible
......
......@@ -131,6 +131,6 @@ is omitted, the tag is removed from the todo item.
-a : Do not change the current value of the tag if it exists, but add a new
value.
-f : Force setting/removing all values of the tag. Prevents interaction with the
user.
-f : Force setting/removing all values of the tag. Prevents interaction with
the user.
"""
......@@ -203,7 +203,9 @@ class _Config:
hidden_tags.split(',')]
def priority_colors(self):
""" Returns a dict with priorities as keys and color numbers as value. """
"""
Returns a dict with priorities as keys and color numbers as value.
"""
pri_colors_str = self.cp.get('colorscheme', 'priority_colors')
def _str_to_dict(p_string):
......
......@@ -36,7 +36,8 @@ class DCommand(MultiCommand):
self.force = False
self.length = len(self.todolist.todos()) # to determine newly activated todos
# to determine newly activated todos
self.length = len(self.todolist.todos())
def get_flags(self):
return ("f", ["force"])
......
......@@ -80,11 +80,11 @@ class MultiCommand(ExpressionCommand):
def _catch_todo_errors(self):
"""
Returns None or list of error messages depending on number of valid todo
objects and number of invalid todo IDs.
Returns None or list of error messages depending on number of valid
todo objects and number of invalid todo IDs.
In case of multiple invalid todo IDs we generate separate error message for each
one of them with information about supplied ID.
In case of multiple invalid todo IDs we generate separate error message
for each one of them with information about supplied ID.
"""
errors = []
......
......@@ -124,7 +124,8 @@ class TodoBase(object):
# Build a new list that excludes the specified tag, match by value when
# p_value is given.
self.fields['tags'] = [t for t in self.fields['tags'] \
if not (t[0] == p_key and (p_value == "" or t[1] == p_value))]
if not (t[0] == p_key and (p_value == "" or
t[1] == p_value))]
# when value == "", match any value having key p_key
value = p_value if p_value != "" else r'\S+'
......@@ -206,7 +207,8 @@ class TodoBase(object):
self.fields['completionDate'] = p_completion_date
self.src = re.sub(r'^(\([A-Z]\) )?', \
'x ' + p_completion_date.isoformat() + ' ', self.src)
'x ' + p_completion_date.isoformat() + ' ',
self.src)
def set_creation_date(self, p_date=date.today()):
"""
......@@ -220,8 +222,8 @@ class TodoBase(object):
self.src = re.sub(
r'^(x \d{4}-\d{2}-\d{2} |\([A-Z]\) )?(\d{4}-\d{2}-\d{2} )?(.*)$',
lambda m: \
u("{}{} {}").format(m.group(1) or '', p_date.isoformat(), m.group(3)),
self.src)
u("{}{} {}").format(m.group(1) or '', p_date.isoformat(),
m.group(3)), self.src)
def creation_date(self):
""" Returns the creation date of a todo. """
......
......@@ -133,7 +133,9 @@ class TodoListBase(object):
return result
def add(self, p_src):
""" Given a todo string, parse it and put it to the end of the list. """
"""
Given a todo string, parse it and put it to the end of the list.
"""
todos = self.add_list([p_src])
return todos[0] if len(todos) else None
......@@ -248,8 +250,8 @@ class TodoListBase(object):
def _update_todo_ids(self):
# the idea is to have a hash that is independent of the position of the
# todo. Use the text (without tags) of the todo to keep the id as stable
# as possible (not influenced by priorities or due dates, etc.)
# todo. Use the text (without tags) of the todo to keep the id as
# stable as possible (not influenced by priorities or due dates, etc.)
self._todo_id_map = {}
self._id_todo_map = {}
......
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