X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=tests%2Ftodos.py;h=059bd9f4fb47fac79a710b8421995f3f4b869da1;hb=a58f0f088ef7bed064a7752aeebb03498b692e8b;hp=3158ecb3abe5a7457245ec4fdf554095edd0389c;hpb=e60bbd142b5026748ee2181ca6758afef6202fb4;p=plomtask diff --git a/tests/todos.py b/tests/todos.py index 3158ecb..059bd9f 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -10,6 +10,8 @@ from plomtask.exceptions import (NotFoundException, BadFormatException, class TestsWithDB(TestCaseWithDB): """Tests requiring DB, but not server setup.""" checked_class = Todo + default_init_kwargs = {'process': None, 'is_done': False, + 'date': '2024-01-01'} def setUp(self) -> None: super().setUp() @@ -21,6 +23,7 @@ class TestsWithDB(TestCaseWithDB): self.cond1.save(self.db_conn) self.cond2 = Condition(None) self.cond2.save(self.db_conn) + self.default_init_kwargs['process'] = self.proc def test_Todo_init(self) -> None: """Test creation of Todo and what they default to.""" @@ -42,17 +45,6 @@ class TestsWithDB(TestCaseWithDB): self.assertEqual(todo_yes_id.enables, []) self.assertEqual(todo_yes_id.disables, []) - def test_Todo_saving_and_caching(self) -> None: - """Test .save.""" - kwargs = {'id_': 1, - 'process': self.proc, - 'is_done': False, - 'date': self.date1} - self.check_saving_and_caching(**kwargs) - todo = Todo(None, self.proc, False, self.date1) - todo.save(self.db_conn) - self.assertEqual(todo.id_, 2) - def test_Todo_by_id(self) -> None: """Test findability of Todos.""" todo = Todo(1, self.proc, False, self.date1) @@ -272,15 +264,15 @@ class TestsWithServer(TestCaseWithServer): self.check_post({}, '/todo?id=FOO', 400) self.check_post({}, '/todo?id=0', 404) # test posting naked entity - todo1 = post_and_reload({'comment': ''}) + todo1 = post_and_reload({}) self.assertEqual(todo1.children, []) self.assertEqual(todo1.parents, []) self.assertEqual(todo1.is_done, False) # test posting doneness - todo1 = post_and_reload({'done': '', 'comment': ''}) + todo1 = post_and_reload({'done': ''}) self.assertEqual(todo1.is_done, True) # test implicitly posting non-doneness - todo1 = post_and_reload({'comment': ''}) + todo1 = post_and_reload({}) self.assertEqual(todo1.is_done, False) # test malformed adoptions self.check_post({'adopt': 'foo'}, '/todo?id=1', 400) @@ -290,17 +282,17 @@ class TestsWithServer(TestCaseWithServer): self.check_post({'day_comment': '', 'new_todo': 1}, '/day?date=2024-01-01', 302) # test todo 1 adopting todo 2 - todo1 = post_and_reload({'adopt': 2, 'comment': ''}) + todo1 = post_and_reload({'adopt': 2}) todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1] self.assertEqual(todo1.children, [todo2]) self.assertEqual(todo1.parents, []) self.assertEqual(todo2.children, []) self.assertEqual(todo2.parents, [todo1]) # test todo1 cannot be set done with todo2 not done yet - todo1 = post_and_reload({'done': '', 'adopt': 2, 'comment': ''}, 400) + todo1 = post_and_reload({'done': '', 'adopt': 2}, 400) self.assertEqual(todo1.is_done, False) # test todo1 un-adopting todo 2 by just not sending an adopt - todo1 = post_and_reload({'comment': ''}, 302) + todo1 = post_and_reload({}, 302) todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1] self.assertEqual(todo1.children, []) self.assertEqual(todo1.parents, [])