home · contact · privacy
Refactor request handler identifying items by ID param on GET.
[plomtask] / tests / todos.py
index 4bc1411b74cbddace9cf0a745527c0dcbb971b1d..0998c690494e60ae864e929e205c16549b4ebe9a 100644 (file)
@@ -125,10 +125,11 @@ class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
         assert isinstance(todo_1.id_, int)
         # test minimum
         node_0 = TodoNode(todo_1, False, [])
-        self.assertEqual(todo_1.get_step_tree(set()), node_0)
+        self.assertEqual(todo_1.get_step_tree(set()).as_dict, node_0.as_dict)
         # test non_emtpy seen_todo does something
         node_0.seen = True
-        self.assertEqual(todo_1.get_step_tree({todo_1.id_}), node_0)
+        self.assertEqual(todo_1.get_step_tree({todo_1.id_}).as_dict,
+                         node_0.as_dict)
         # test child shows up
         todo_2 = Todo(None, self.proc, False, self.date1)
         todo_2.save(self.db_conn)
@@ -137,7 +138,7 @@ class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
         node_2 = TodoNode(todo_2, False, [])
         node_0.children = [node_2]
         node_0.seen = False
-        self.assertEqual(todo_1.get_step_tree(set()), node_0)
+        self.assertEqual(todo_1.get_step_tree(set()).as_dict, node_0.as_dict)
         # test child shows up with child
         todo_3 = Todo(None, self.proc, False, self.date1)
         todo_3.save(self.db_conn)
@@ -145,12 +146,12 @@ class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
         todo_2.add_child(todo_3)
         node_3 = TodoNode(todo_3, False, [])
         node_2.children = [node_3]
-        self.assertEqual(todo_1.get_step_tree(set()), node_0)
+        self.assertEqual(todo_1.get_step_tree(set()).as_dict, node_0.as_dict)
         # test same todo can be child-ed multiple times at different locations
         todo_1.add_child(todo_3)
         node_4 = TodoNode(todo_3, True, [])
         node_0.children += [node_4]
-        self.assertEqual(todo_1.get_step_tree(set()), node_0)
+        self.assertEqual(todo_1.get_step_tree(set()).as_dict, node_0.as_dict)
 
     def test_Todo_create_with_children(self) -> None:
         """Test parenthood guaranteeds of Todo.create_with_children."""
@@ -273,7 +274,7 @@ class TestsWithServer(TestCaseWithServer):
                         '/day?date=2024-01-01&make_type=full', 302)
         # test posting to bad URLs
         self.check_post({}, '/todo=', 404)
-        self.check_post({}, '/todo?id=', 400)
+        self.check_post({}, '/todo?id=', 404)
         self.check_post({}, '/todo?id=FOO', 400)
         self.check_post({}, '/todo?id=0', 404)
         # test posting naked entity
@@ -399,11 +400,12 @@ class TestsWithServer(TestCaseWithServer):
         form_data = {'day_comment': '', 'new_todo': [1], 'make_type': 'full'}
         self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         todo = Todo.by_date(self.db_conn, '2024-01-01')[0]
-        form_data = {'day_comment': '', 'todo_id': [1], 'make_type': 'full'}
+        form_data = {'day_comment': '', 'todo_id': [1], 'make_type': 'full',
+                     'comment': [''], 'done': [], 'effort': ['']}
         self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         self.assertEqual(todo.is_done, False)
         form_data = {'day_comment': '', 'todo_id': [1], 'done': [1],
-                     'make_type': 'full'}
+                     'make_type': 'full', 'comment': [''], 'effort': ['']}
         self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         self.assertEqual(todo.is_done, True)
 
@@ -412,8 +414,8 @@ class TestsWithServer(TestCaseWithServer):
         self.post_process()
         form_data = {'day_comment': '', 'new_todo': 1, 'make_type': 'full'}
         self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
-        self.check_get('/todo', 400)
-        self.check_get('/todo?id=', 400)
+        self.check_get('/todo', 404)
+        self.check_get('/todo?id=', 404)
         self.check_get('/todo?id=foo', 400)
         self.check_get('/todo?id=0', 404)
         self.check_get('/todo?id=1', 200)