"""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}
+ proc_post = {'title': 'A', 'description': '', 'effort': 1.0}
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])
+ proc2_dict = self.proc_as_dict(2, explicit_steps=[1])
+ proc3_dict = self.proc_as_dict(3, explicit_steps=[2])
+ proc4_dict = self.proc_as_dict(4, 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),
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)
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_POST_todo_make_empty(self) -> None:
+ """Test creation and adoption via POST /todo with "make_empty"."""
+ # pylint: disable=too-many-locals
+ # create chain of Processes
+ proc_post = {'title': 'A', 'description': '', 'effort': 1.0}
+ 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, explicit_steps=[1])
+ proc3_dict = self.proc_as_dict(3, explicit_steps=[2])
+ proc4_dict = self.proc_as_dict(4, 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 empty 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, parents=[1])
+ todos = [todo1_dict, todo2_dict]
+ expected = self.GET_todo_dict(1, todos, procs, procsteps)
+ step_proc1 = self._step_as_dict(3, [], 1, None)
+ step_proc2 = self._step_as_dict(2, [step_proc1], 2, None, True)
+ step_proc3 = self._step_as_dict(1, [step_proc2], 3, 2, True)
+ expected['steps_todo_to_process'] = [step_proc3]
+ expected['todo_candidates'] = [2]
+ expected['adoption_candidates_for'] = {'1': [], '2': []}
+ self.check_post({'fill_for_3': 'make_empty_3'}, '/todo?id=1')
+ self.check_json_get('/todo?id=1', expected)
+ # make new top-level Todo without chain implied by its Process
+ self.check_post({'make_empty': 2, 'adopt': [2]}, '/todo?id=1')
+ todo3_dict = self.todo_as_dict(3, 2, parents=[1], children=[])
+ todo1_dict['children'] = [2, 3]
+ todos += [todo3_dict]
+ step2_proc2 = self._step_as_dict(4, [], None, 3)
+ expected = self.GET_todo_dict(1, todos, procs, procsteps)
+ expected['todo_candidates'] = [2, 3]
+ expected['steps_todo_to_process'] = [step_proc3, step2_proc2]
+ expected['adoption_candidates_for'] = {'1': [], '2': [3]}
+ 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)