From: Christian Heller Date: Wed, 15 May 2024 07:50:51 +0000 (+0200) Subject: For Todo POST, treat un-sent comment field as empty one. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/todos?a=commitdiff_plain;h=32c0e270d3c521329c0b7a988b25585e6a275ff5;p=plomtask For Todo POST, treat un-sent comment field as empty one. --- diff --git a/plomtask/http.py b/plomtask/http.py index 2ecfcaa..98bb49f 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -248,7 +248,7 @@ class TaskHandler(BaseHTTPRequestHandler): todo.set_enables(self.conn, self.form_data.get_all_int('enables')) todo.set_disables(self.conn, self.form_data.get_all_int('disables')) todo.is_done = len(self.form_data.get_all_str('done')) > 0 - todo.comment = self.form_data.get_str('comment') + todo.comment = self.form_data.get_str('comment', ignore_strict=True) todo.save(self.conn) for condition in todo.enables: condition.save(self.conn) diff --git a/tests/todos.py b/tests/todos.py index 3158ecb..419d3db 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -272,15 +272,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 +290,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, [])