Commit eac37bab authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add tests for groups

parent e9411143
+A only test:test_group1
+B only test:test_group1
+A and +B test:test_group1
No project test:test_group1
Different item test:test_group2 l:1
Another item test:test_group2 l:0
Test 1 due:2016-12-06 test:test_group3
Test 2 due:2016-12-07 test:test_group3
Test 1 t:2016-12-06 test:test_group4 test:test_group5
Test 2 t:2016-12-07 test:test_group4 test:test_group5
Group by non-existing tag test:test_group6
Sort descending +A test:test_group7
Sort descending +B test:test_group7
Inner sort 1 +A @A test:test_group8
Inner sort 2 +A @B test:test_group8
Inner sort 3 +B @A test:test_group8
Inner sort 4 +B @B test:test_group8
Inner sort 1 +A test:test_group9
Inner sort 2 +A test:test_group9
......@@ -552,5 +552,172 @@ class ListCommandDotTest(CommandTest):
self.assertEqual(self.errors, "")
@freeze_time('2016, 12, 6')
class ListCommandGroupTest(CommandTest):
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_group2(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-g", "l", "test:test_group2"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
l: 0
====
| 6| Another item l:0 test:test_group2
l: 1
====
| 5| Different item l:1 test:test_group2
""")
def test_group3(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-g", "due", "test:test_group3"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
due: today
==========
| 7| Test 1 test:test_group3 due:2016-12-06
due: in a day
=============
| 8| Test 2 test:test_group3 due:2016-12-07
""")
def test_group4(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-g", "t", "test:test_group4"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
t: today
========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
""")
def test_group5(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-x", "-g", "t", "test:test_group5"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
t: today
========
| 9| Test 1 test:test_group4 test:test_group5 t:2016-12-06
t: in a day
===========
| 10| Test 2 test:test_group4 test:test_group5 t:2016-12-07
""")
def test_group6(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-x", "-g", "fake", "test_group6"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
fake: No value
==============
| 11| Group by non-existing tag test:test_group6
""")
def test_group7(self):
todolist = load_file_to_todolist("test/data/ListCommandGroupTest.txt")
command = ListCommand(["-x", "-g", "desc:project", "test_group7"], todolist, self.out, self.error)
command.execute()
self.assertFalse(todolist.dirty)
self.assertEqual(self.output, """\
Project: B
==========
| 13| Sort descending +B test:test_group7
Project: A
==========
| 12| Sort descending +A test:test_group7
""")
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_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
""")
if __name__ == '__main__':
unittest.main()
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