From: Tomas Babej Date: Fri, 19 Dec 2014 08:09:57 +0000 (+0100) Subject: tests: Add basic Task tests X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/71b09c9d8f0af7799bbe634dfdafccb08e7d9f00 tests: Add basic Task tests --- diff --git a/tasklib/tests.py b/tasklib/tests.py index 2fa1371..2af697f 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -70,6 +70,53 @@ class TaskFilterTest(TasklibTest): self.assertEqual(no_priority_task['description'], "no priority task") +class TaskTest(TasklibTest): + + def test_create_unsaved_task(self): + # Make sure a new task is not saved unless explicitly called for + t = Task(self.tw, description="test task") + self.assertEqual(len(self.tw.tasks.all()), 0) + + def test_delete_unsaved_task(self): + with self.assertRaises(Task.NotSaved): + t = Task(self.tw, description="test task") + t.delete() + + def test_complete_unsaved_task(self): + with self.assertRaises(Task.NotSaved): + t = Task(self.tw, description="test task") + t.done() + + def test_refresh_unsaved_task(self): + with self.assertRaises(Task.NotSaved): + t = Task(self.tw, description="test task") + t.refresh() + + def test_delete_deleted_task(self): + t = Task(self.tw, description="test task") + t.save() + t.delete() + + with self.assertRaises(Task.DeletedTask): + t.delete() + + def test_complete_completed_task(self): + t = Task(self.tw, description="test task") + t.save() + t.done() + + with self.assertRaises(Task.CompletedTask): + t.done() + + def test_complete_deleted_task(self): + t = Task(self.tw, description="test task") + t.save() + t.delete() + + with self.assertRaises(Task.DeletedTask): + t.done() + + class AnnotationTest(TasklibTest): def setUp(self):