home · contact · privacy
Hide (almost all) remaining SQL code in DB module.
[plomtask] / tests / todos.py
index a90f466cb99a201d353ea5434d5ea9c336dae0da..426bb91c4b6635f77ef74e95acd9d8d4624c14f6 100644 (file)
@@ -121,19 +121,21 @@ class TestsWithDB(TestCaseWithDB):
         """Test Todo.children relations."""
         todo_1 = Todo(None, self.proc, False, self.date1)
         todo_2 = Todo(None, self.proc, False, self.date1)
+        todo_2.save(self.db_conn)
         with self.assertRaises(HandledException):
             todo_1.add_child(todo_2)
         todo_1.save(self.db_conn)
+        todo_3 = Todo(None, self.proc, False, self.date1)
         with self.assertRaises(HandledException):
-            todo_1.add_child(todo_2)
-        todo_2.save(self.db_conn)
-        todo_1.add_child(todo_2)
+            todo_1.add_child(todo_3)
+        todo_3.save(self.db_conn)
+        todo_1.add_child(todo_3)
         todo_1.save(self.db_conn)
         assert isinstance(todo_1.id_, int)
         todo_retrieved = Todo.by_id(self.db_conn, todo_1.id_)
-        self.assertEqual(todo_retrieved.children, [todo_2])
+        self.assertEqual(todo_retrieved.children, [todo_3])
         with self.assertRaises(BadFormatException):
-            todo_2.add_child(todo_1)
+            todo_3.add_child(todo_1)
 
     def test_Todo_conditioning(self) -> None:
         """Test Todo.doability conditions."""
@@ -208,7 +210,7 @@ class TestsWithServer(TestCaseWithServer):
         self.check_post(form_data, '/day?date=2024-01-01', 302, '/')
         form_data = {}
         self.check_post(form_data, '/todo=', 404)
-        self.check_post(form_data, '/todo?id=', 404)
+        self.check_post(form_data, '/todo?id=', 400)
         self.check_post(form_data, '/todo?id=FOO', 400)
         self.check_post(form_data, '/todo?id=0', 404)
         todo1 = post_and_reload(form_data)
@@ -247,8 +249,8 @@ class TestsWithServer(TestCaseWithServer):
         self.check_post(form_data, '/process?id=', 302, '/')
         form_data = {'comment': '', 'new_todo': 1}
         self.check_post(form_data, '/day?date=2024-01-01', 302, '/')
-        self.check_get('/todo', 404)
-        self.check_get('/todo?id=', 404)
+        self.check_get('/todo', 400)
+        self.check_get('/todo?id=', 400)
         self.check_get('/todo?id=foo', 400)
         self.check_get('/todo?id=0', 404)
         self.check_get('/todo?id=1', 200)