home · contact · privacy
Minor improvements to Todo tests.
[plomtask] / tests / todos.py
index ecf2089a4b0544866004fdbb97521dbbc0b03fcf..1c86db60a999a2e086a8d971d225f1497b9b2355 100644 (file)
@@ -1,14 +1,19 @@
 """Test Todos module."""
-from tests.utils import TestCaseWithDB, TestCaseWithServer
+from typing import Any
+from tests.utils import TestCaseSansDB, TestCaseWithDB, TestCaseWithServer
 from plomtask.todos import Todo, TodoNode
-from plomtask.processes import Process
+from plomtask.processes import Process, ProcessStep
 from plomtask.conditions import Condition
 from plomtask.exceptions import (NotFoundException, BadFormatException,
                                  HandledException)
 
 
-class TestsWithDB(TestCaseWithDB):
-    """Tests requiring DB, but not server setup."""
+class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
+    """Tests requiring DB, but not server setup.
+
+    NB: We subclass TestCaseSansDB too, to run any tests there that due to any
+    Todo requiring a _saved_ Process wouldn't run without a DB.
+    """
     checked_class = Todo
     default_init_kwargs = {'process': None, 'is_done': False,
                            'date': '2024-01-01'}
@@ -45,16 +50,6 @@ class TestsWithDB(TestCaseWithDB):
         self.assertEqual(todo_yes_id.enables, [])
         self.assertEqual(todo_yes_id.disables, [])
 
-    def test_Todo_by_id(self) -> None:
-        """Test findability of Todos."""
-        todo = Todo(1, self.proc, False, self.date1)
-        todo.save(self.db_conn)
-        self.assertEqual(Todo.by_id(self.db_conn, 1), todo)
-        with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, 0)
-        with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, 2)
-
     def test_Todo_by_date(self) -> None:
         """Test findability of Todos by date."""
         t1 = Todo(None, self.proc, False, self.date1)
@@ -66,6 +61,10 @@ class TestsWithDB(TestCaseWithDB):
         with self.assertRaises(BadFormatException):
             self.assertEqual(Todo.by_date(self.db_conn, 'foo'), [])
 
+    def test_Todo_by_date_range_with_limits(self) -> None:
+        """Test .by_date_range_with_limits."""
+        self.check_by_date_range_with_limits('day')
+
     def test_Todo_on_conditions(self) -> None:
         """Test effect of Todos on Conditions."""
         assert isinstance(self.cond1.id_, int)
@@ -122,15 +121,24 @@ class TestsWithDB(TestCaseWithDB):
 
     def test_Todo_step_tree(self) -> None:
         """Test self-configuration of TodoStepsNode tree for Day view."""
+
+        def todo_node_as_dict(node: TodoNode) -> dict[str, object]:
+            return {'todo': node.todo.id_, 'seen': node.seen,
+                    'children': [todo_node_as_dict(c) for c in node.children]}
+
         todo_1 = Todo(None, self.proc, False, self.date1)
         todo_1.save(self.db_conn)
         assert isinstance(todo_1.id_, int)
         # test minimum
         node_0 = TodoNode(todo_1, False, [])
-        self.assertEqual(todo_1.get_step_tree(set()), node_0)
+        cmp_0_dict = todo_node_as_dict(todo_1.get_step_tree(set()))
+        cmp_1_dict = todo_node_as_dict(node_0)
+        self.assertEqual(cmp_0_dict, cmp_1_dict)
         # test non_emtpy seen_todo does something
         node_0.seen = True
-        self.assertEqual(todo_1.get_step_tree({todo_1.id_}), node_0)
+        cmp_0_dict = todo_node_as_dict(todo_1.get_step_tree({todo_1.id_}))
+        cmp_1_dict = todo_node_as_dict(node_0)
+        self.assertEqual(cmp_0_dict, cmp_1_dict)
         # test child shows up
         todo_2 = Todo(None, self.proc, False, self.date1)
         todo_2.save(self.db_conn)
@@ -139,7 +147,9 @@ class TestsWithDB(TestCaseWithDB):
         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)
+        cmp_0_dict = todo_node_as_dict(todo_1.get_step_tree(set()))
+        cmp_1_dict = todo_node_as_dict(node_0)
+        self.assertEqual(cmp_0_dict, cmp_1_dict)
         # test child shows up with child
         todo_3 = Todo(None, self.proc, False, self.date1)
         todo_3.save(self.db_conn)
@@ -147,12 +157,16 @@ class TestsWithDB(TestCaseWithDB):
         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)
+        cmp_0_dict = todo_node_as_dict(todo_1.get_step_tree(set()))
+        cmp_1_dict = todo_node_as_dict(node_0)
+        self.assertEqual(cmp_0_dict, cmp_1_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)
+        cmp_0_dict = todo_node_as_dict(todo_1.get_step_tree(set()))
+        cmp_1_dict = todo_node_as_dict(node_0)
+        self.assertEqual(cmp_0_dict, cmp_1_dict)
 
     def test_Todo_create_with_children(self) -> None:
         """Test parenthood guaranteeds of Todo.create_with_children."""
@@ -167,11 +181,13 @@ class TestsWithDB(TestCaseWithDB):
         proc4.save(self.db_conn)
         assert isinstance(proc4.id_, int)
         # make proc4 step of proc3
-        proc3.set_steps(self.db_conn, [(None, proc4.id_, None)])
+        step = ProcessStep(None, proc3.id_, proc4.id_, None)
+        proc3.set_steps(self.db_conn, [step])
         # give proc2 three steps; 2× proc1, 1× proc3
-        proc2.set_steps(self.db_conn, [(None, self.proc.id_, None),
-                                       (None, self.proc.id_, None),
-                                       (None, proc3.id_, None)])
+        step1 = ProcessStep(None, proc2.id_, self.proc.id_, None)
+        step2 = ProcessStep(None, proc2.id_, self.proc.id_, None)
+        step3 = ProcessStep(None, proc2.id_, proc3.id_, None)
+        proc2.set_steps(self.db_conn, [step1, step2, step3])
         # test mere creation does nothing
         todo_ignore = Todo(None, proc2, False, self.date1)
         todo_ignore.save(self.db_conn)
@@ -185,29 +201,27 @@ class TestsWithDB(TestCaseWithDB):
         todo_2 = Todo.create_with_children(self.db_conn, proc2.id_, self.date1)
         self.assertEqual(3, len(todo_2.children))
         self.assertEqual(todo_1, todo_2.children[0])
-        self.assertEqual(self.proc, todo_2.children[1].process)
-        self.assertEqual(proc3, todo_2.children[2].process)
-        todo_3 = todo_2.children[2]
+        self.assertEqual(self.proc, todo_2.children[2].process)
+        self.assertEqual(proc3, todo_2.children[1].process)
+        todo_3 = todo_2.children[1]
         self.assertEqual(len(todo_3.children), 1)
         self.assertEqual(todo_3.children[0].process, proc4)
 
-    def test_Todo_singularity(self) -> None:
-        """Test pointers made for single object keep pointing to it."""
-        self.check_singularity('is_done', True, self.proc, False, self.date1)
-
     def test_Todo_remove(self) -> None:
         """Test removal."""
         todo_1 = Todo(None, self.proc, False, self.date1)
         todo_1.save(self.db_conn)
+        assert todo_1.id_ is not None
         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_id = todo_1.id_
         todo_1.remove(self.db_conn)
         with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, todo_1.id_)
+            Todo.by_id(self.db_conn, todo_1_id)
         self.assertEqual(todo_0.children, [])
         self.assertEqual(todo_2.parents, [])
         todo_2.comment = 'foo'
@@ -225,102 +239,306 @@ class TestsWithDB(TestCaseWithDB):
         todo_1.comment = 'foo'
         todo_1.effort = -0.1
         todo_1.save(self.db_conn)
+        assert todo_1.id_ is not None
         Todo.by_id(self.db_conn, todo_1.id_)
         todo_1.comment = ''
+        todo_1_id = todo_1.id_
         todo_1.save(self.db_conn)
         with self.assertRaises(NotFoundException):
-            Todo.by_id(self.db_conn, todo_1.id_)
+            Todo.by_id(self.db_conn, todo_1_id)
 
 
 class TestsWithServer(TestCaseWithServer):
     """Tests against our HTTP server/handler (and database)."""
 
+    def setUp(self) -> None:
+        super().setUp()
+        self._proc1_form_data: Any = self.post_process(1)
+        self._date = '2024-01-01'
+
+    @classmethod
+    def GET_todo_dict(cls,
+                      target_id: int,
+                      todos: list[dict[str, object]],
+                      processes: list[dict[str, object]],
+                      process_steps: list[dict[str, object]] | None = None,
+                      ) -> dict[str, object]:
+        """Return JSON of GET /todo to expect."""
+        library = {'Todo': cls.as_refs(todos),
+                   'Process': cls.as_refs(processes)}
+        if process_steps:
+            library['ProcessStep'] = cls.as_refs(process_steps)
+        return {'todo': target_id,
+                'steps_todo_to_process': [],
+                'adoption_candidates_for': {},
+                'process_candidates': [p['id'] for p in processes],
+                'todo_candidates': [],
+                'condition_candidates': [],
+                '_library': library}
+
+    @staticmethod
+    def _step_as_dict(node_id: int,
+                      children: list[dict[str, object]],
+                      process: int | None = None,
+                      todo: int | None = None,
+                      fillable: bool = False,
+                      ) -> dict[str, object]:
+        return {'node_id': node_id,
+                'children': children,
+                'process': process,
+                'fillable': fillable,
+                'todo': todo}
+
+    def _make_todo_via_day_post(self, proc_id: int) -> None:
+        payload = {'day_comment': '',
+                   'new_todo': proc_id,
+                   'make_type': 'empty'}
+        self.check_post(payload, f'/day?date={self._date}&make_type=empty')
+
+    def test_basic_fail_POST_todo(self) -> None:
+        """Test basic malformed/illegal POST /todo requests."""
+        # test we cannot just POST into non-existing Todo
+        self.check_post({}, '/todo', 404)
+        self.check_post({}, '/todo?id=FOO', 400)
+        self.check_post({}, '/todo?id=0', 404)
+        self.check_post({}, '/todo?id=1', 404)
+        # test malformed values on existing Todo
+        self._make_todo_via_day_post(1)
+        for name in ['adopt', 'effort', 'make_full', 'make_empty',
+                     'conditions', 'disables', 'blockers', 'enables']:
+            self.check_post({name: 'x'}, '/todo?id=1', 400, '/todo')
+        for prefix in ['make_empty_', 'make_full_']:
+            for suffix in ['', 'x', '1.1']:
+                self.check_post({'fill_for_1': f'{prefix}{suffix}'},
+                                '/todo?id=1', 400, '/todo')
+
+    def test_basic_POST_todo(self) -> None:
+        """Test basic POST /todo manipulations."""
+        self._make_todo_via_day_post(1)
+        # test posting naked entity at first changes nothing
+        todo_dict = self.todo_as_dict(1, 1)
+        proc_dict = self.proc_as_dict(**self._proc1_form_data)
+        expected = self.GET_todo_dict(1, [todo_dict], [proc_dict])
+        self.check_json_get('/todo?id=1', expected)
+        self.check_post({}, '/todo?id=1')
+        self.check_json_get('/todo?id=1', expected)
+        # test posting doneness, comment, calendarization, effort
+        todo_post = {'done': '', 'calendarize': '', 'comment': 'foo',
+                     'effort': 2.3}
+        todo_dict = self.todo_as_dict(1, 1, is_done=True, calendarize=True,
+                                      comment='foo', effort=2.3)
+        expected = self.GET_todo_dict(1, [todo_dict], [proc_dict])
+        self.check_post(todo_post, '/todo?id=1')
+        self.check_json_get('/todo?id=1', expected)
+        # test implicitly un-setting all of those except effort by empty post
+        self.check_post({}, '/todo?id=1')
+        todo_dict = self.todo_as_dict(1, 1, effort=2.3)
+        expected = self.GET_todo_dict(1, [todo_dict], [proc_dict])
+        self.check_json_get('/todo?id=1', expected)
+        # test empty effort post can be explicitly unset by "" post
+        self.check_post({'effort': ''}, '/todo?id=1')
+        todo_dict['effort'] = None
+        self.check_json_get('/todo?id=1', expected)
+
+    def test_POST_todo_deletion(self) -> None:
+        """Test deletions via POST /todo."""
+        self._make_todo_via_day_post(1)
+        todo_dict = self.todo_as_dict(1, process_id=1)
+        proc_dict = self.proc_as_dict(**self._proc1_form_data)
+        expected = self.GET_todo_dict(1, [todo_dict], [proc_dict])
+        # test failure of deletion on non-existing Todo
+        self.check_post({'delete': ''}, '/todo?id=2', 404, '/')
+        # test deletion of existing Todo
+        self.check_post({'delete': ''}, '/todo?id=1', 302, '/')
+        self.check_get('/todo?id=1', 404)
+        # test deletion of adopted Todo
+        self._make_todo_via_day_post(1)
+        self._make_todo_via_day_post(1)
+        self.check_post({'adopt': 2}, '/todo?id=1')
+        self.check_post({'delete': ''}, '/todo?id=2', 302, '/')
+        self.check_json_get('/todo?id=1', expected)
+        # test deletion of adopting Todo
+        self._make_todo_via_day_post(1)
+        self.check_post({'adopt': 2}, '/todo?id=1')
+        self.check_post({'delete': ''}, '/todo?id=1', 302, '/')
+        todo_dict['id'] = 2
+        expected = self.GET_todo_dict(2, [todo_dict], [proc_dict])
+        self.check_json_get('/todo?id=2', expected)
+
+    def test_POST_todo_adoption(self) -> None:
+        """Test adoption via POST /todo with "adopt"."""
+        # post two Todos to Day, have first adopt second
+        self._make_todo_via_day_post(1)
+        self._make_todo_via_day_post(1)
+        proc_dict = self.proc_as_dict(**self._proc1_form_data)
+        todo1_dict = self.todo_as_dict(1, process_id=1, children=[2])
+        todo2_dict = self.todo_as_dict(2, process_id=1, parents=[1])
+        expected = self.GET_todo_dict(1, [todo1_dict, todo2_dict], [proc_dict])
+        expected['todo_candidates'] = [2]
+        expected['steps_todo_to_process'] = [self._step_as_dict(1, [], todo=2)]
+        self.check_post({'adopt': 2}, '/todo?id=1')
+        self.check_json_get('/todo?id=1', expected)
+        # test Todo cannot be set done with adopted Todo not done yet
+        self.check_post({'adopt': 2, 'done': ''}, '/todo?id=1', 400)
+        self.check_json_get('/todo?id=1', expected)
+        # test Todo un-adopting by just not sending an adopt
+        self.check_post({}, '/todo?id=1')
+        todo1_dict['children'] = []
+        todo2_dict['parents'] = []
+        expected['steps_todo_to_process'] = []
+        self.check_json_get('/todo?id=1', expected)
+        # test fail on trying to adopt non-existing Todo
+        self.check_post({'adopt': 3}, '/todo?id=1', 404)
+        # test cannot self-adopt
+        self.check_post({'adopt': 1}, '/todo?id=1', 400)
+        # test cannot do 1-step circular adoption
+        self.check_post({'adopt': 1}, '/todo?id=2')
+        self.check_post({'adopt': 2}, '/todo?id=1', 400)
+        # test cannot do 2-step circular adoption
+        self._make_todo_via_day_post(1)
+        self.check_post({'adopt': 2}, '/todo?id=3')
+        self.check_post({'adopt': 3}, '/todo?id=1', 400)
+
+    def test_POST_todo_make_full(self) -> None:
+        """Test creation and adoption via POST /todo with "make_full"."""
+        # pylint: disable=too-many-locals
+        # create chain of Processes
+        proc_post = {'title': '', 'description': '', 'effort': 0.9}
+        self.post_process(2, proc_post | {'new_top_step': 1})
+        self.post_process(3, proc_post | {'new_top_step': 2})
+        self.post_process(4, proc_post | {'new_top_step': 3})
+        proc1_dict = self.proc_as_dict(**self._proc1_form_data)
+        proc2_dict = self.proc_as_dict(2, '', '', 0.9, explicit_steps=[1])
+        proc3_dict = self.proc_as_dict(3, '', '', 0.9, explicit_steps=[2])
+        proc4_dict = self.proc_as_dict(4, '', '', 0.9, explicit_steps=[3])
+        procs = [proc1_dict, proc2_dict, proc3_dict, proc4_dict]
+        procsteps = [self.procstep_as_dict(1, 2, 1),
+                     self.procstep_as_dict(2, 3, 2),
+                     self.procstep_as_dict(3, 4, 3)]
+        # post (childless) Todo of chain end, then make_full on next in line
+        self._make_todo_via_day_post(4)
+        todo1_dict = self.todo_as_dict(1, 4, children=[2])
+        todo2_dict = self.todo_as_dict(2, 3, children=[3], parents=[1])
+        todo3_dict = self.todo_as_dict(3, 2, parents=[2], children=[4])
+        todo4_dict = self.todo_as_dict(4, 1, parents=[3])
+        todos = [todo1_dict, todo2_dict, todo3_dict, todo4_dict]
+        expected = self.GET_todo_dict(1, todos, procs, procsteps)
+        step_proc1 = self._step_as_dict(3, [], 1, 4, True)
+        step_proc2 = self._step_as_dict(2, [step_proc1], 2, 3, True)
+        step_proc3 = self._step_as_dict(1, [step_proc2], 3, 2, True)
+        expected['steps_todo_to_process'] = [step_proc3]
+        expected['process_candidates'] = [4, 3, 2, 1]
+        expected['todo_candidates'] = [2, 3, 4]
+        self.check_post({'fill_for_3': 'make_full_3'}, '/todo?id=1')
+        self.check_json_get('/todo?id=1', expected)
+        # make new chain next to expected, find steps_todo_to_process extended,
+        # expect existing Todo demanded by new chain be adopted into new chain
+        self.check_post({'make_full': 2, 'adopt': [2]}, '/todo?id=1')
+        todo5_dict = self.todo_as_dict(5, 2, parents=[1], children=[4])
+        todo1_dict['children'] = [2, 5]
+        todo4_dict['parents'] = [3, 5]
+        todos += [todo5_dict]
+        step2_proc1 = self._step_as_dict(5, [], None, 4)
+        step2_proc2 = self._step_as_dict(4, [step2_proc1], None, 5)
+        expected = self.GET_todo_dict(1, todos, procs, procsteps)
+        expected['process_candidates'] = [4, 3, 2, 1]
+        expected['todo_candidates'] = [2, 3, 4, 5]
+        expected['steps_todo_to_process'] = [step_proc3, step2_proc2]
+        self.check_json_get('/todo?id=1', expected)
+
+    def test_do_GET_todo(self) -> None:
+        """Test GET /todo response codes."""
+        self._make_todo_via_day_post(1)
+        # test malformed or illegal parameter values
+        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=2', 404)
+        # test all existing Processes are shown as available
+        proc_post = {'title': 'A', 'description': '', 'effort': 1.0}
+        self.post_process(2, proc_post)
+        todo1_dict = self.todo_as_dict(1, process_id=1)
+        proc1_dict = self.proc_as_dict(1, **self._proc1_form_data)
+        proc2_dict = self.proc_as_dict(2)
+        procs = [proc1_dict, proc2_dict]
+        expected = self.GET_todo_dict(1, [todo1_dict], procs)
+        self.check_json_get('/todo?id=1', expected)
+        # test chain of Processes shown as potential step nodes
+        self.post_process(2, proc_post)
+        self.post_process(3, proc_post)
+        self.post_process(4, proc_post)
+        self.post_process(1, self._proc1_form_data | {'new_top_step': 2})
+        self.post_process(2, proc_post | {'new_top_step': 3, 'step_of': [1]})
+        self.post_process(3, proc_post | {'new_top_step': 4, 'step_of': [2]})
+        proc1_dict['explicit_steps'] = [1]
+        proc2_dict['explicit_steps'] = [2]
+        proc3_dict = self.proc_as_dict(3, explicit_steps=[3])
+        proc4_dict = self.proc_as_dict(4)
+        procs += [proc3_dict, proc4_dict]
+        procsteps = [self.procstep_as_dict(1, 1, 2, None),
+                     self.procstep_as_dict(2, 2, 3, None),
+                     self.procstep_as_dict(3, 3, 4, None)]
+        expected = self.GET_todo_dict(1, [todo1_dict], procs, procsteps)
+        step_proc4 = self._step_as_dict(3, [], 4)
+        step_proc3 = self._step_as_dict(2, [step_proc4], 3)
+        step_proc2 = self._step_as_dict(1, [step_proc3], 2, fillable=True)
+        expected['steps_todo_to_process'] = [step_proc2]
+        expected['adoption_candidates_for'] = {'2': [], '3': [], '4': []}
+        self.check_json_get('/todo?id=1', expected)
+        # test display of parallel chains
+        proc_steps_post = {'new_top_step': 4, 'keep_step': [1],
+                           'step_1_process_id': 2, 'steps': [1, 4]}
+        self.post_process(1, self._proc1_form_data | proc_steps_post)
+        proc1_dict['explicit_steps'] = [1, 4]
+        step2_proc4 = self._step_as_dict(4, [], 4, fillable=True)
+        procsteps += [self.procstep_as_dict(4, 1, 4, None)]
+        expected = self.GET_todo_dict(1, [todo1_dict], procs, procsteps)
+        expected['steps_todo_to_process'] = [step_proc2, step2_proc4]
+        expected['adoption_candidates_for'] = {'2': [], '3': [], '4': []}
+        self.check_json_get('/todo?id=1', expected)
+
     def test_do_POST_day(self) -> None:
         """Test Todo posting of POST /day."""
-        self.post_process()
         self.post_process(2)
         proc = Process.by_id(self.db_conn, 1)
         proc2 = Process.by_id(self.db_conn, 2)
-        form_data = {'day_comment': ''}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        # check posting no Todos to Day makes Todo.by_date return empty list
+        form_data = {'day_comment': '', 'make_type': 'full'}
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         self.assertEqual(Todo.by_date(self.db_conn, '2024-01-01'), [])
+        proc = Process.by_id(self.db_conn, 1)
+        # post Todo to Day and check its display
         form_data['new_todo'] = str(proc.id_)
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         todos = Todo.by_date(self.db_conn, '2024-01-01')
         self.assertEqual(1, len(todos))
         todo1 = todos[0]
         self.assertEqual(todo1.id_, 1)
+        proc = Process.by_id(self.db_conn, 1)
         self.assertEqual(todo1.process.id_, proc.id_)
         self.assertEqual(todo1.is_done, False)
+        # post second Todo, check its appearance
+        proc2 = Process.by_id(self.db_conn, 2)
         form_data['new_todo'] = str(proc2.id_)
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         todos = Todo.by_date(self.db_conn, '2024-01-01')
         todo1 = todos[1]
         self.assertEqual(todo1.id_, 2)
+        proc2 = Process.by_id(self.db_conn, 1)
+        todo1 = Todo.by_date(self.db_conn, '2024-01-01')[0]
+        self.assertEqual(todo1.id_, 1)
         self.assertEqual(todo1.process.id_, proc2.id_)
         self.assertEqual(todo1.is_done, False)
 
-    def test_do_POST_todo(self) -> None:
-        """Test POST /todo."""
-        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
-        self.post_process()
-        self.check_post({'day_comment': '', 'new_todo': 1},
-                        '/day?date=2024-01-01', 302)
-        # test posting to bad URLs
-        self.check_post({}, '/todo=', 404)
-        self.check_post({}, '/todo?id=', 400)
-        self.check_post({}, '/todo?id=FOO', 400)
-        self.check_post({}, '/todo?id=0', 404)
-        # test posting naked entity
-        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': ''})
-        self.assertEqual(todo1.is_done, True)
-        # test implicitly posting non-doneness
-        todo1 = post_and_reload({})
-        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({'day_comment': '', 'new_todo': 1},
-                        '/day?date=2024-01-01', 302)
-        # test todo 1 adopting todo 2
-        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}, 400)
-        self.assertEqual(todo1.is_done, False)
-        # test todo1 un-adopting todo 2 by just not sending an adopt
-        todo1 = post_and_reload({}, 302)
-        todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
-        self.assertEqual(todo1.children, [])
-        self.assertEqual(todo1.parents, [])
-        self.assertEqual(todo2.children, [])
-        self.assertEqual(todo2.parents, [])
-        # test todo1 deletion
-        todo1 = post_and_reload({'delete': ''}, 302, '/')
-
     def test_do_POST_day_todo_adoption(self) -> None:
         """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 = {'day_comment': '', 'new_todo': 1}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        form_data = self.post_process(
+                2, self._proc1_form_data | {'new_top_step': 1})
+        form_data = {'day_comment': '', 'new_todo': 1, 'make_type': 'full'}
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         form_data['new_todo'] = 2
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         todo1 = Todo.by_date(self.db_conn, '2024-01-01')[0]
         todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
         self.assertEqual(todo1.children, [])
@@ -330,10 +548,11 @@ class TestsWithServer(TestCaseWithServer):
 
     def test_do_POST_day_todo_multiple(self) -> None:
         """Test multiple Todos can be posted to Day view."""
-        form_data = self.post_process()
+        form_data = self.post_process()
         form_data = self.post_process(2)
-        form_data = {'day_comment': '', 'new_todo': [1, 2]}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        form_data = {'day_comment': '', 'new_todo': [1, 2],
+                     'make_type': 'full'}
+        self.check_post(form_data, '/day?date=2024-01-01&make_type=full', 302)
         todo1 = Todo.by_date(self.db_conn, '2024-01-01')[0]
         todo2 = Todo.by_date(self.db_conn, '2024-01-01')[1]
         self.assertEqual(todo1.process.id_, 1)
@@ -347,8 +566,9 @@ class TestsWithServer(TestCaseWithServer):
             return t.process.id_
 
         def check_adoption(date: str, new_todos: list[int]) -> None:
-            form_data = {'day_comment': '', 'new_todo': new_todos}
-            self.check_post(form_data, f'/day?date={date}', 302)
+            form_data = {'day_comment': '', 'new_todo': new_todos,
+                         'make_type': 'full'}
+            self.check_post(form_data, f'/day?date={date}&make_type=full', 302)
             day_todos = Todo.by_date(self.db_conn, date)
             day_todos.sort(key=key_order_func)
             todo1 = day_todos[0]
@@ -360,12 +580,15 @@ class TestsWithServer(TestCaseWithServer):
 
         def check_nesting_adoption(process_id: int, date: str,
                                    new_top_steps: list[int]) -> None:
-            form_data = self.post_process()
-            form_data = self.post_process(process_id,
-                                          form_data |
-                                          {'new_top_step': new_top_steps})
-            form_data = {'day_comment': '', 'new_todo': [process_id]}
-            self.check_post(form_data, f'/day?date={date}', 302)
+            form_data = {'title': '', 'description': '', 'effort': 1,
+                         'step_of': [2]}
+            form_data = self.post_process(1, form_data)
+            form_data['new_top_step'] = new_top_steps
+            form_data['step_of'] = []
+            form_data = self.post_process(process_id, form_data)
+            form_data = {'day_comment': '', 'new_todo': [process_id],
+                         'make_type': 'full'}
+            self.check_post(form_data, f'/day?date={date}&make_type=full', 302)
             day_todos = Todo.by_date(self.db_conn, date)
             day_todos.sort(key=key_order_func, reverse=True)
             self.assertEqual(len(day_todos), 3)
@@ -379,8 +602,7 @@ class TestsWithServer(TestCaseWithServer):
             self.assertEqual(todo3.children, [])
             self.assertEqual(sorted(todo3.parents), sorted([todo2, todo1]))
 
-        form_data = self.post_process()
-        form_data = self.post_process(2, form_data | {'new_top_step': 1})
+        self.post_process(2, self._proc1_form_data | {'new_top_step': 1})
         check_adoption('2024-01-01', [1, 2])
         check_adoption('2024-01-02', [2, 1])
         check_nesting_adoption(3, '2024-01-03', [1, 2])
@@ -388,24 +610,16 @@ class TestsWithServer(TestCaseWithServer):
 
     def test_do_POST_day_todo_doneness(self) -> None:
         """Test Todo doneness can be posted to Day view."""
-        form_data = self.post_process()
-        form_data = {'day_comment': '', 'new_todo': [1]}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        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',
+                     'comment': [''], 'done': [], 'effort': ['']}
+        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]}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
         self.assertEqual(todo.is_done, False)
-        form_data = {'day_comment': '', 'todo_id': [1], 'done': [1]}
-        self.check_post(form_data, '/day?date=2024-01-01', 302)
+        form_data = {'day_comment': '', 'todo_id': [1], 'done': [1],
+                     'make_type': 'full', 'comment': [''], 'effort': ['']}
+        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]
         self.assertEqual(todo.is_done, True)
-
-    def test_do_GET_todo(self) -> None:
-        """Test GET /todo response codes."""
-        self.post_process()
-        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)
-        self.check_get('/todo?id=foo', 400)
-        self.check_get('/todo?id=0', 404)
-        self.check_get('/todo?id=1', 200)