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.
   7 from .task import TaskWarrior
 
  10 class TasklibTest(unittest.TestCase):
 
  13         self.tmp = tempfile.mkdtemp(dir='.')
 
  14         self.tw = TaskWarrior(data_location=self.tmp)
 
  17         shutil.rmtree(self.tmp)
 
  20 class TaskFilterTest(TasklibTest):
 
  22     def test_all_empty(self):
 
  23         self.assertEqual(len(self.tw.tasks.all()), 0)
 
  25     def test_all_non_empty(self):
 
  26         self.tw.execute_command(['add', 'test task'])
 
  27         self.assertEqual(len(self.tw.tasks.all()), 1)
 
  28         self.assertEqual(self.tw.tasks.all()[0]['description'], 'test task')
 
  29         self.assertEqual(self.tw.tasks.all()[0]['status'], 'pending')
 
  31     def test_pending_non_empty(self):
 
  32         self.tw.execute_command(['add', 'test task'])
 
  33         self.assertEqual(len(self.tw.tasks.pending()), 1)
 
  34         self.assertEqual(self.tw.tasks.pending()[0]['description'],
 
  36         self.assertEqual(self.tw.tasks.pending()[0]['status'], 'pending')
 
  38     def test_completed_empty(self):
 
  39         self.tw.execute_command(['add', 'test task'])
 
  40         self.assertEqual(len(self.tw.tasks.completed()), 0)
 
  42     def test_completed_non_empty(self):
 
  43         self.tw.execute_command(['add', 'test task'])
 
  44         self.assertEqual(len(self.tw.tasks.completed()), 0)
 
  45         self.tw.tasks.all()[0].done()
 
  46         self.assertEqual(len(self.tw.tasks.completed()), 1)
 
  49 class AnnotationTest(TasklibTest):
 
  52         super(AnnotationTest, self).setUp()
 
  53         self.tw.execute_command(['add', 'test task'])
 
  55     def test_adding_annotation(self):
 
  56         task = self.tw.tasks.get()
 
  57         task.add_annotation('test annotation')
 
  58         self.assertEqual(len(task['annotations']), 1)
 
  59         ann = task['annotations'][0]
 
  60         self.assertEqual(ann['description'], 'test annotation')
 
  62     def test_removing_annotation(self):
 
  63         task = self.tw.tasks.get()
 
  64         task.add_annotation('test annotation')
 
  65         ann = task['annotations'][0]
 
  67         self.assertEqual(len(task['annotations']), 0)
 
  69     def test_removing_annotation_by_description(self):
 
  70         task = self.tw.tasks.get()
 
  71         task.add_annotation('test annotation')
 
  72         task.remove_annotation('test annotation')
 
  73         self.assertEqual(len(task['annotations']), 0)
 
  75     def test_removing_annotation_by_obj(self):
 
  76         task = self.tw.tasks.get()
 
  77         task.add_annotation('test annotation')
 
  78         ann = task['annotations'][0]
 
  79         task.remove_annotation(ann)
 
  80         self.assertEqual(len(task['annotations']), 0)
 
  83 class UnicodeTest(TasklibTest):
 
  85     def test_unicode_task(self):
 
  86         self.tw.execute_command(['add', '†åßk'])
 
  89     def test_non_unicode_task(self):
 
  90         self.tw.execute_command(['add', 'task'])