]> git.madduck.net Git - etc/taskwarrior.git/blob - tasklib/tests.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Ugh. Just test taskwarrior 2.1.x and 2.2.x
[etc/taskwarrior.git] / tasklib / tests.py
1 import shutil
2 import tempfile
3 import unittest
4
5 from .task import TaskWarrior
6
7
8 class TasklibTest(unittest.TestCase):
9
10     def setUp(self):
11         self.tmp = tempfile.mkdtemp(dir='.')
12         self.tw = TaskWarrior(data_location=self.tmp)
13
14     def tearDown(self):
15         shutil.rmtree(self.tmp)
16
17
18 class TaskFilterTest(TasklibTest):
19
20     def test_all_empty(self):
21         self.assertEqual(len(self.tw.tasks.all()), 0)
22
23     def test_all_non_empty(self):
24         self.tw.execute_command(['add', 'test task'])
25         self.assertEqual(len(self.tw.tasks.all()), 1)
26         self.assertEqual(self.tw.tasks.all()[0]['description'], 'test task')
27         self.assertEqual(self.tw.tasks.all()[0]['status'], 'pending')
28
29     def test_pending_non_empty(self):
30         self.tw.execute_command(['add', 'test task'])
31         self.assertEqual(len(self.tw.tasks.pending()), 1)
32         self.assertEqual(self.tw.tasks.pending()[0]['description'],
33                          'test task')
34         self.assertEqual(self.tw.tasks.pending()[0]['status'], 'pending')
35
36     def test_completed_empty(self):
37         self.tw.execute_command(['add', 'test task'])
38         self.assertEqual(len(self.tw.tasks.completed()), 0)
39
40     def test_completed_non_empty(self):
41         self.tw.execute_command(['add', 'test task'])
42         self.assertEqual(len(self.tw.tasks.completed()), 0)
43         self.tw.tasks.all()[0].done()
44         self.assertEqual(len(self.tw.tasks.completed()), 1)
45
46
47 class AnnotationTest(TasklibTest):
48
49     def setUp(self):
50         super(AnnotationTest, self).setUp()
51         self.tw.execute_command(['add', 'test task'])
52
53     def test_adding_annotation(self):
54         task = self.tw.tasks.get()
55         task.add_annotation('test annotation')
56         self.assertEqual(len(task['annotations']), 1)
57         ann = task['annotations'][0]
58         self.assertEqual(ann['description'], 'test annotation')
59
60     def test_removing_annotation(self):
61         task = self.tw.tasks.get()
62         task.add_annotation('test annotation')
63         ann = task['annotations'][0]
64         ann.remove()
65         self.assertEqual(len(task['annotations']), 0)
66
67     def test_removing_annotation_by_description(self):
68         task = self.tw.tasks.get()
69         task.add_annotation('test annotation')
70         task.remove_annotation('test annotation')
71         self.assertEqual(len(task['annotations']), 0)
72
73     def test_removing_annotation_by_obj(self):
74         task = self.tw.tasks.get()
75         task.add_annotation('test annotation')
76         ann = task['annotations'][0]
77         task.remove_annotation(ann)
78         self.assertEqual(len(task['annotations']), 0)