X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=tests%2Ftodos.py;h=b85f2d105f0f09e174f13de88506b309ccfc4f3d;hb=a99b13325a21042825450d2497ddf61f8c5c3644;hp=182bd5566bff159e152fa7156e90e42c8a3caa8d;hpb=e14580b4ee47363cad317e4ec1de91affe03d53a;p=plomtask diff --git a/tests/todos.py b/tests/todos.py index 182bd55..b85f2d1 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -266,6 +266,22 @@ class TestsWithDB(TestCaseWithDB): retrieved_todo.is_done = False self.assertEqual(todo.is_done, False) + def test_Todo_remove(self) -> None: + """Test removal.""" + todo_1 = Todo(None, self.proc, False, self.date1) + todo_1.save(self.db_conn) + todo_0 = Todo(None, self.proc, False, self.date1) + todo_0.save(self.db_conn) + todo_0.add_child(todo_1) + todo_2 = Todo(None, self.proc, False, self.date1) + todo_2.save(self.db_conn) + todo_1.add_child(todo_2) + todo_1.remove(self.db_conn) + with self.assertRaises(NotFoundException): + Todo.by_id(self.db_conn, todo_1.id_) + self.assertEqual(todo_0.children, []) + self.assertEqual(todo_2.parents, []) + class TestsWithServer(TestCaseWithServer): """Tests against our HTTP server/handler (and database).""" @@ -298,9 +314,9 @@ class TestsWithServer(TestCaseWithServer): def test_do_POST_todo(self) -> None: """Test POST /todo.""" - def post_and_reload(form_data: dict[str, object], - status: int = 302) -> Todo: - self.check_post(form_data, '/todo?id=1', status) + def post_and_reload(form_data: dict[str, object], status: int = 302, + redir_url: str = '/todo?id=1') -> Todo: + self.check_post(form_data, '/todo?id=1', status, redir_url) return Todo.by_date(self.db_conn, '2024-01-01')[0] # test minimum form_data = {'title': '', 'description': '', 'effort': 1} @@ -356,6 +372,9 @@ class TestsWithServer(TestCaseWithServer): self.assertEqual(todo1.parents, []) self.assertEqual(todo2.children, []) self.assertEqual(todo2.parents, []) + # test todo1 deletion + form_data = {'delete': ''} + todo1 = post_and_reload(form_data, 302, '/') def test_do_POST_day_todo_adoption(self) -> None: """Test Todos posted to Day view may adopt existing Todos."""