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.
5 from .task import TaskWarrior
8 class TasklibTest(unittest.TestCase):
11 self.tmp = tempfile.mkdtemp(dir='.')
12 self.tw = TaskWarrior(data_location=self.tmp)
15 shutil.rmtree(self.tmp)
18 class TaskFilterTest(TasklibTest):
20 def test_all_empty(self):
21 self.assertEqual(len(self.tw.tasks.all()), 0)
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')
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'],
34 self.assertEqual(self.tw.tasks.pending()[0]['status'], 'pending')
36 def test_completed_empty(self):
37 self.tw.execute_command(['add', 'test task'])
38 self.assertEqual(len(self.tw.tasks.completed()), 0)
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)
47 class AnnotationTest(TasklibTest):
50 super(AnnotationTest, self).setUp()
51 self.tw.execute_command(['add', 'test task'])
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')
60 def test_removing_annotation(self):
61 task = self.tw.tasks.get()
62 task.add_annotation('test annotation')
63 ann = task['annotations'][0]
65 self.assertEqual(len(task['annotations']), 0)
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)
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)