def test_list8(self): command = ListCommand(["--", "-project1"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list_format47(self): command = ListCommand(["-x", "-F", "%(r)"], self.todolist, self.out, self.error) command.execute() error = 'Error while parsing format string (list_format config option or -F)\n' self.assertEqual(self.output, '') self.assertEqual(self.errors, error)
def test_list7(self): command = ListCommand(["-s", "text", "-x", "Project1"], 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| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list41(self): command = ListCommand(["-z", "Zzz"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "") self.assertEqual(self.errors, "option -z not recognized\n")
def test_list05(self): command = ListCommand(["-x"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.errors, "")
def test_list15(self): command = ListCommand(["p:<10"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list35(self): """ -x flag takes precedence over -n """ command = ListCommand(["-x", "-n", "foo"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n|7| hidden item h:1\n|6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.errors, "")
def test_list33(self): """ Negative values result in showing all relevent todos. """ command = ListCommand(["-n", "-1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list4(self): command = ListCommand(["-x", "Context1"], 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| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list18(self): command = ListCommand(["-x", "date:2014-12-12"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 6| x 2014-12-12 Completed but with date:2014-12-12\n")
def test_list31(self): """ Don't show any todos with -n 0 """ command = ListCommand(["-n", "0"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "") self.assertEqual(self.errors, "")
def test_list06(self): command = ListCommand(["Project3"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "") self.assertEqual(self.errors, "")
def test_list15(self): command = ListCommand(["p:<10"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list17(self): command = ListCommand(["-x", "id:"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "| 3| (C) Baz @Context1 +Project1 key:value\n") self.assertEqual(self.errors, "")
def test_group8(self): todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt") command = ListCommand(["-x", "-g", "project,desc:context", "test_group8"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.dirty) self.assertEqual(self.output, """\ Project: A, Context: B ====================== |15| Inner sort 2 +A @B test:test_group8 Project: A, Context: A ====================== |14| Inner sort 1 +A @A test:test_group8 Project: B, Context: B ====================== |17| Inner sort 4 +B @B test:test_group8 Project: B, Context: A ====================== |16| Inner sort 3 +B @A test:test_group8 """)
def test_list10(self): command = ListCommand(["text1", "2"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list09(self): command = ListCommand(["--", "-project1", "-Drink"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_group1(self): todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt") command = ListCommand(["-g", "project", "test:test_group1"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.dirty) self.assertEqual( self.output, """\ Project: A ========== | 1| +A only test:test_group1 | 3| +A and +B test:test_group1 Project: B ========== | 3| +A and +B test:test_group1 | 2| +B only test:test_group1 Project: None ============= | 4| No project test:test_group1 """)
def test_list05(self): command = ListCommand(["-x"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n|7| hidden item h:1\n|6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.errors, "")
def test_group11(self): config(p_overrides={('sort', 'group_string'): 'project'}) todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt") command = ListCommand(["test:test_group1"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.dirty) self.assertEqual(self.output, """\ Project: A ========== | 1| +A only test:test_group1 | 3| +A and +B test:test_group1 Project: B ========== | 3| +A and +B test:test_group1 | 2| +B only test:test_group1 Project: None ============= | 4| No project test:test_group1 """) self.assertEqual(self.errors, "")
def test_list32(self): """ Only show the top todo. """ command = ListCommand(["-n", "1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list01(self): command = ListCommand([""], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list32(self): """ Only show the top todo. """ command = ListCommand(["-n", "1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list42(self): command = ListCommand(["-x", "+Project1", "-id:1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list18(self): command = ListCommand(["-x", "date:2014-12-12"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|6| x 2014-12-12 Completed but with date:2014-12-12\n")
def test_list33(self): """ Negative values result in showing all relevent todos. """ command = ListCommand(["-n", "-1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list35(self): """ -x flag takes precedence over -n """ command = ListCommand(["-x", "-n", "foo"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n| 6| x 2014-12-12 Completed but with date:2014-12-12\n") self.assertEqual(self.errors, "")
def test_list01(self): command = ListCommand([""], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_help(self): command = ListCommand(["help"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "") self.assertEqual(self.errors, command.usage() + "\n\n" + command.help() + "\n")
def test_list43(self): """Test basic 'N' parameter.""" command = ListCommand(["-N"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n| 5| (C) 13 + 29 = 42\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list42(self): command = ListCommand(["-x", "+Project1", "-id:1"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list10(self): command = ListCommand(["text1", "2"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list39(self): config("test/data/todolist-uid.conf") command = ListCommand(["-i", "t5c,foo"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|t5c| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list08(self): command = ListCommand(["--", "-project1"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list04(self): command = ListCommand(["-x", "Context1"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|3| (C) Baz @Context1 +Project1 key:value\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list07(self): command = ListCommand(["-s", "text", "-x", "Project1"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|3| (C) Baz @Context1 +Project1 key:value\n|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list34(self): """ Test non-integer value for -n """ config(p_overrides={('ls', 'list_limit'): '2'}) command = ListCommand(["-n", "foo"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n") self.assertEqual(self.errors, "")
def test_list11(self): config("test/data/listcommand.conf") command = ListCommand(["project"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list16(self): config("test/data/todolist-uid.conf") command = ListCommand([], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "|t5c| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|wa5| (C) Drink beer @ home\n|z63| (C) 13 + 29 = 42\n|mfg| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list34(self): """ Test non-integer value for -n """ config(p_overrides={('ls', 'list_limit'): '2'}) command = ListCommand(["-n", "foo"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 4| (C) Drink beer @ home\n") self.assertEqual(self.errors, "")
def test_list16(self): config("test/data/todolist-uid.conf") command = ListCommand([], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|t5c| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|wa5| (C) Drink beer @ home\n|z63| (C) 13 + 29 = 42\n|mfg| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list17(self): 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.errors, "")
def test_list12(self): config("test/data/listcommand.conf") command = ListCommand(["-x", "project"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, "| 1| (C) Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n| 2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list14(self): config("test/data/listcommand2.conf") command = ListCommand([], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, " |1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n |4| (C) Drink beer @ home\n |5| (C) 13 + 29 = 42\n |2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list37(self): command = ListCommand(["-i", "1,foo,3"], self.todolist, self.out, self.error) command.execute() self.assertEqual( self.output, "| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n| 3| (C) Baz @Context1 +Project1 key:value\n", ) self.assertEqual(self.errors, "")
def test_list43(self, mock_terminal_size): """Test basic 'N' parameter.""" mock_terminal_size.return_value = self.terminal_size(81, 100) command = ListCommand(["-N"], self.todolist, self.out, self.error) command.execute() self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|4| (C) Drink beer @ home\n|5| (C) 13 + 29 = 42\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")
def test_list11(self): config("test/data/listcommand.conf") command = ListCommand(["project"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n") self.assertEqual(self.errors, "")
def test_list22(self): """ Handle tag lists with spaces and punctuation.""" config(p_overrides={('ls', 'hide_tags'): 'p, id'}) self.todolist = load_file_to_todolist('test/data/ListCommandTagTest.txt') command = ListCommand(["-x"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, '|1| Foo.\n')
def test_group10(self): todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt") command = ListCommand(["-x", "-g"], todolist, self.out, self.error) command.execute() self.assertFalse(todolist.dirty) self.assertEqual(self.output, "") self.assertEqual(self.errors, "option -g requires argument\n")
def test_list22(self): """ Handle tag lists with spaces and punctuation.""" config(p_overrides={('ls', 'hide_tags'): 'p, id'}) self.todolist = load_file_to_todolist('test/data/ListCommandTagTest.txt') command = ListCommand(["-x"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.is_dirty()) self.assertEqual(self.output, '| 1| Foo.\n')
def test_list_unicode1(self): """ Unicode filters.""" command = ListCommand([u"\u25c4"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) expected = u"|1| (C) And some sp\u00e9cial tag:\u25c4\n" self.assertEqual(self.output, expected)
def test_list37(self): command = ListCommand(["-i", "1,foo,3"], self.todolist, self.out, self.error) command.execute() self.assertEqual( self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n" ) self.assertEqual(self.errors, "")
def test_list12(self): config("test/data/listcommand.conf") command = ListCommand(["-x", "project"], self.todolist, self.out, self.error) command.execute() self.assertFalse(self.todolist.dirty) self.assertEqual(self.output, "|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n|3| (C) Baz @Context1 +Project1 key:value\n|2| (D) Bar @Context1 +Project2\n") self.assertEqual(self.errors, "")