home · contact · privacy
Add Todo.comment display/posting in Todo view.
[plomtask] / tests / todos.py
index 0633547d3613c7a8b01f79964885c9f476f64c2f..3158ecb3abe5a7457245ec4fdf554095edd0389c 100644 (file)
@@ -237,7 +237,7 @@ class TestsWithServer(TestCaseWithServer):
         self.post_process(2)
         proc = Process.by_id(self.db_conn, 1)
         proc2 = Process.by_id(self.db_conn, 2)
-        form_data = {'comment': ''}
+        form_data = {'day_comment': ''}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         self.assertEqual(Todo.by_date(self.db_conn, '2024-01-01'), [])
         form_data['new_todo'] = str(proc.id_)
@@ -264,7 +264,7 @@ class TestsWithServer(TestCaseWithServer):
             return Todo.by_date(self.db_conn, '2024-01-01')[0]
         # test minimum
         self.post_process()
-        self.check_post({'comment': '', 'new_todo': 1},
+        self.check_post({'day_comment': '', 'new_todo': 1},
                         '/day?date=2024-01-01', 302)
         # test posting to bad URLs
         self.check_post({}, '/todo=', 404)
@@ -272,35 +272,35 @@ 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({})
+        todo1 = post_and_reload({'comment': ''})
         self.assertEqual(todo1.children, [])
         self.assertEqual(todo1.parents, [])
         self.assertEqual(todo1.is_done, False)
         # test posting doneness
-        todo1 = post_and_reload({'done': ''})
+        todo1 = post_and_reload({'done': '', 'comment': ''})
         self.assertEqual(todo1.is_done, True)
         # test implicitly posting non-doneness
-        todo1 = post_and_reload({})
+        todo1 = post_and_reload({'comment': ''})
         self.assertEqual(todo1.is_done, False)
         # test malformed adoptions
         self.check_post({'adopt': 'foo'}, '/todo?id=1', 400)
         self.check_post({'adopt': 1}, '/todo?id=1', 400)
         self.check_post({'adopt': 2}, '/todo?id=1', 404)
         # test posting second todo of same process
-        self.check_post({'comment': '', 'new_todo': 1},
+        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})
+        todo1 = post_and_reload({'adopt': 2, 'comment': ''})
         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}, 400)
+        todo1 = post_and_reload({'done': '', 'adopt': 2, 'comment': ''}, 400)
         self.assertEqual(todo1.is_done, False)
         # test todo1 un-adopting todo 2 by just not sending an adopt
-        todo1 = post_and_reload({}, 302)
+        todo1 = post_and_reload({'comment': ''}, 302)
         todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
         self.assertEqual(todo1.children, [])
         self.assertEqual(todo1.parents, [])
@@ -313,7 +313,7 @@ class TestsWithServer(TestCaseWithServer):
         """Test Todos posted to Day view may adopt existing Todos."""
         form_data = self.post_process()
         form_data = self.post_process(2, form_data | {'new_top_step': 1})
-        form_data = {'comment': '', 'new_todo': 1}
+        form_data = {'day_comment': '', 'new_todo': 1}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         form_data['new_todo'] = 2
         self.check_post(form_data, '/day?date=2024-01-01', 302)
@@ -328,7 +328,7 @@ class TestsWithServer(TestCaseWithServer):
         """Test multiple Todos can be posted to Day view."""
         form_data = self.post_process()
         form_data = self.post_process(2)
-        form_data = {'comment': '', 'new_todo': [1, 2]}
+        form_data = {'day_comment': '', 'new_todo': [1, 2]}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         todo1 = Todo.by_date(self.db_conn, '2024-01-01')[0]
         todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
@@ -339,7 +339,7 @@ class TestsWithServer(TestCaseWithServer):
         """Test multiple Todos can be posted to Day view w. inner adoption."""
         form_data = self.post_process()
         form_data = self.post_process(2, form_data | {'new_top_step': 1})
-        form_data = {'comment': '', 'new_todo': [1, 2]}
+        form_data = {'day_comment': '', 'new_todo': [1, 2]}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         todo1 = Todo.by_date(self.db_conn, '2024-01-01')[0]
         todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
@@ -348,7 +348,7 @@ class TestsWithServer(TestCaseWithServer):
         self.assertEqual(todo2.children, [todo1])
         self.assertEqual(todo2.parents, [])
         # check process ID order does not affect end result
-        form_data = {'comment': '', 'new_todo': [2, 1]}
+        form_data = {'day_comment': '', 'new_todo': [2, 1]}
         self.check_post(form_data, '/day?date=2024-01-02', 302)
         todo1 = Todo.by_date(self.db_conn, '2024-01-02')[1]
         todo2 = Todo.by_date(self.db_conn, '2024-01-02')[0]
@@ -358,22 +358,22 @@ class TestsWithServer(TestCaseWithServer):
         self.assertEqual(todo2.parents, [])
 
     def test_do_POST_day_todo_doneness(self) -> None:
-        """Test multiple Todos can be posted to Day view."""
+        """Test Todo doneness can be posted to Day view."""
         form_data = self.post_process()
-        form_data = {'comment': '', 'new_todo': [1]}
+        form_data = {'day_comment': '', 'new_todo': [1]}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         todo = Todo.by_date(self.db_conn, '2024-01-01')[0]
-        form_data = {'comment': '', 'todo_id': [1]}
+        form_data = {'day_comment': '', 'todo_id': [1]}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         self.assertEqual(todo.is_done, False)
-        form_data = {'comment': '', 'todo_id': [1], 'done': [1]}
+        form_data = {'day_comment': '', 'todo_id': [1], 'done': [1]}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         self.assertEqual(todo.is_done, True)
 
     def test_do_GET_todo(self) -> None:
         """Test GET /todo response codes."""
         self.post_process()
-        form_data = {'comment': '', 'new_todo': 1}
+        form_data = {'day_comment': '', 'new_todo': 1}
         self.check_post(form_data, '/day?date=2024-01-01', 302)
         self.check_get('/todo', 400)
         self.check_get('/todo?id=', 400)