Exemple #1
0
    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_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, "")
Exemple #3
0
    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_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_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_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_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_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, "")
Exemple #9
0
    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, "")
Exemple #10
0
    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")
Exemple #11
0
    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, "")
Exemple #12
0
    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_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_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_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, "")
Exemple #16
0
    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, "")
Exemple #17
0
    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, "")
Exemple #18
0
    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
""")
Exemple #19
0
    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, "")
Exemple #20
0
    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, "")
Exemple #21
0
    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)
Exemple #22
0
    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, "")
Exemple #23
0
    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, "")
Exemple #24
0
    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, "")
Exemple #25
0
    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_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, "")
Exemple #27
0
    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, "")
Exemple #28
0
    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, "")
Exemple #29
0
    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')
Exemple #30
0
    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_list_format24(self):
        command = ListCommand(["-x", "-F", "%K"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """due:2015-09-30 t:2015-09-29
due:2015-11-08 lazy:bar t:2015-11-07

key:value
ical:foobar id:1 p:2
date:2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format28(self):
        command = ListCommand(["-x", "-F", "%t"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """2015-09-29
2015-11-07




"""
        self.assertEqual(self.output, result)
    def test_list_format29(self):
        command = ListCommand(["-x", "-F", "%T"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """a month ago
in a day




"""
        self.assertEqual(self.output, result)
    def test_list_format30(self):
        command = ListCommand(["-x", "-F", "%x"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """




x 2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format32(self):
        command = ListCommand(["-x", "-s", "desc:priority", "-F", "%{{}p{}}"],
                              self.todolist, self.out, self.error)
        command.execute()

        result = """{C}
{C}
{D}


{Z}
"""
        self.assertEqual(self.output, result)
    def test_list_format31(self):
        command = ListCommand(["-x", "-F", "%X"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """




x 11 months ago
"""
        self.assertEqual(self.output, result)
    def test_list_format43(self):
        command = ListCommand(["-x", "-F", "%P -"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """D -
Z -
C -
C -
  -
  -
"""
        self.assertEqual(self.output, result)
    def test_list_format34(self):
        command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p%p"],
                              self.todolist, self.out, self.error)
        command.execute()

        result = """CC
CC
DD


ZZ
"""
        self.assertEqual(self.output, result)
    def test_list_format46(self):
        command = ListCommand(["-x", "-F", "%r"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """(D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
(Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the lazy:bar and jar due:2015-11-08 t:2015-11-07
(C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
(C) Baz @Context1 +Project1 key:value
Drink beer @ home id:1 p:2 ical:foobar
x 2014-12-12 Completed but with date:2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format44(self):
        command = ListCommand(["-x", "-F", "%i %{(}P{)}"], self.todolist,
                              self.out, self.error)
        command.execute()

        result = """1 (D)
2 (Z)
3 (C)
4 (C)
5 ( )
6 ( )
"""
        self.assertEqual(self.output, result)
    def test_list_format10(self):
        config(p_overrides={('ls', 'list_format'): '|%i| %k'})
        command = ListCommand(["-x"], self.todolist, self.out, self.error)
        command.execute()

        result = """|1|
|2| lazy:bar
|3|
|4| key:value
|5|
|6| date:2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format11(self):
        config(p_overrides={('ls', 'list_format'): '|%I| %K'})
        command = ListCommand(["-x"], self.todolist, self.out, self.error)
        command.execute()

        result = """|1| due:2015-09-30 t:2015-09-29
|2| due:2015-11-08 lazy:bar t:2015-11-07
|3|
|4| key:value
|5| ical:foobar id:1 p:2
|6| date:2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format12(self):
        config(p_overrides={('ls', 'list_format'): r'|%I| \%'})
        command = ListCommand(["-x"], self.todolist, self.out, self.error)
        command.execute()

        result = """|1| %
|2| %
|3| %
|4| %
|5| %
|6| %
"""
        self.assertEqual(self.output, result)
    def test_list_format15(self):
        command = ListCommand(["-x", "-F", "%c"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """2015-08-31
2015-11-06
2015-07-12



"""
        self.assertEqual(self.output, result)
    def test_list_format26(self):
        command = ListCommand(["-x", "-F", "%s"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = u"""Bar @Context1 +Project2
Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar
Foo @Context2 Not@Context +Project1 Not+Project
Baz @Context1 +Project1
Drink beer @ home
Completed but with
"""
        self.assertEqual(self.output, result)
    def test_list_format20(self):
        command = ListCommand(["-x", "-F", "%H"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """3 months ago, due a month ago, started a month ago
today, due in 2 days, starts in a day
4 months ago



"""
        self.assertEqual(self.output, result)
    def test_list_format25(self):
        command = ListCommand(["-x", "-F", "%p"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """D
Z
C
C


"""
        self.assertEqual(self.output, result)
    def test_list_format19(self):
        command = ListCommand(["-x", "-F", "%h"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """due a month ago, started a month ago
due in 2 days, starts in a day




"""
        self.assertEqual(self.output, result)
    def test_list_format23(self):
        command = ListCommand(["-x", "-F", "%k"], self.todolist, self.out,
                              self.error)
        command.execute()

        result = """
lazy:bar

key:value

date:2014-12-12
"""
        self.assertEqual(self.output, result)
    def test_list_format13(self):
        command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %s %K"],
                              self.todolist, self.out, self.error)
        command.execute()

        result = """|1| (D) 2015-08-31 Bar @Context1 +Project2 due:2015-09-30 t:2015-09-29
|2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +jumped over the and jar due:2015-11-08 lazy:bar t:2015-11-07
|3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
|4| (C) Baz @Context1 +Project1 key:value
|5| Drink beer @ home ical:foobar id:1 p:2
|6| x 2014-12-12 Completed but with date:2014-12-12
"""
        self.assertEqual(self.output, result)
Exemple #51
0
    def test_list_format50(self):
        """
        Test line numbers
        """
        command = ListCommand(["-F %u"], self.todolist, self.out, self.error)
        command.execute()

        result = """ mfg
 t5c
 n8m
 wa5
"""
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")
    def test_list_format37(self, mock_terminal_size):
        mock_terminal_size.return_value = self.terminal_size(5, 25)
        command = ListCommand(["-x", "-s", "desc:priority", "-F", "	%{ }p"],
                              self.todolist, self.out, self.error)
        command.execute()

        result = """   C
   C
   D


   Z
"""
        self.assertEqual(self.output, result)
    def test_list_format33(self):
        command = ListCommand(
            ["-x", "-s", "desc:priority", "-F", r"%{\%p}p{\%p}"],
            self.todolist, self.out, self.error)
        command.execute()

        result = """%pC%p
%pC%p
%pD%p


%pZ%p
"""
        self.assertEqual(self.output, result)
Exemple #54
0
    def test_list_format27(self, mock_terminal_size):
        mock_terminal_size.return_value = self.terminal_size(50, 25)

        command = ListCommand(["-x", "-F", "%S"], self.todolist, self.out, self.error)
        command.execute()

        result = """Bar @Context1 +Project2
Lorem ipsum dolorem sit amet. Red @fox +jumped...
Foo @Context2 Not@Context +Project1 Not+Project
Baz @Context1 +Project1
Drink beer @ home
Completed but with
"""
        self.assertEqual(self.output, result)
Exemple #55
0
    def test_list_format36(self, mock_terminal_size):
        """Tab expands to 1 character."""
        mock_terminal_size.return_value =  self.terminal_size(6, 25)
        command = ListCommand(["-x", "-s", "desc:priority", "-F", "%p{ }	%{ }p"], self.todolist, self.out, self.error)
        command.execute()

        result = """C   C
C   C
D   D
Z   Z


"""
        self.assertEqual(self.output, result)
Exemple #56
0
    def test_list_format41(self, mock_terminal_size):
        mock_terminal_size.return_value = self.terminal_size(100, 25)

        command = ListCommand(["-x", "-F", "|%I| %x %{(}p{)} %c %S\\t%K"], self.todolist, self.out, self.error)
        command.execute()

        result = """|1| (D) 2015-08-31 Bar @Context1 +Project2                              due:2015-09-30 t:2015-09-29
|2| (Z) 2015-11-06 Lorem ipsum dolorem sit amet. Red @fox +... due:2015-11-08 lazy:bar t:2015-11-07
|3| (C) 2015-07-12 Foo @Context2 Not@Context +Project1 Not+Project
|4| (C) Baz @Context1 +Project1                                                           key:value
|5| Drink beer @ home                                                          ical:foobar id:1 p:2
|6| x 2014-12-12 Completed but with                                                 date:2014-12-12
"""
        self.assertEqual(self.output, result)
Exemple #57
0
    def test_ical_python32(self):
        """
        Test case for Python 3.2 where icalendar is not supported.
        """
        todolist = load_file_to_todolist("test/data/ListCommandTest.txt")

        command = ListCommand(["-f", "ical"], todolist, self.out, self.error)
        command.execute()

        self.assertFalse(todolist.is_dirty())
        self.assertEqual(self.output, '')
        self.assertEqual(
            self.errors,
            "icalendar is not supported in this Python version.\n")
    def test_list19(self):
        """ Force showing all tags. """
        config('test/data/listcommand-tags.conf')

        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 id:1 key:value\n|1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project\n"
        )
        self.assertEqual(self.errors, "")
    def test_group9(self):
        todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")

        command = ListCommand(["-x", "-g", "project", "-s", "desc:text", "test_group9"], todolist, self.out, self.error)
        command.execute()

        self.assertFalse(todolist.dirty)

        self.assertEqual(self.output, """\
Project: A
==========
|19| Inner sort 2 +A test:test_group9
|18| Inner sort 1 +A test:test_group9
""")
Exemple #60
0
    def test_list_format51(self):
        """
        Test padded identifiers
        """
        command = ListCommand(["-F %U"], self.todolist, self.out, self.error)
        command.execute()

        result = """ mfg
 t5c
 n8m
 wa5
"""
        self.assertEqual(self.output, result)
        self.assertEqual(self.errors, "")