]> 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:

Add Travis build status to README
[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)