- def test_POST_todo_make_full(self) -> None:
- """Test creation and adoption via POST /todo with "make_full"."""
- # create chain of Processes
- exp = ExpectedGetTodo(1)
- self.post_exp_process([exp], {}, 1)
- for i in range(1, 4):
- self.post_exp_process([exp], {'new_top_step': i}, i+1)
- exp.lib_set('ProcessStep', [exp.procstep_as_dict(1, 2, 1),
- exp.procstep_as_dict(2, 3, 2),
- exp.procstep_as_dict(3, 4, 3)])
- step3_proc1 = exp.step_as_dict(3, [], 1, None, False)
- step2_proc2 = exp.step_as_dict(2, [step3_proc1], 2, None, False)
- step1_proc3 = exp.step_as_dict(1, [step2_proc2], 3, None, True)
- exp.set('steps_todo_to_process', [step1_proc3])
- # post (childless) Todo of chain end, then make_full on next in line
- self.post_exp_day([exp], {'new_todo': [4]})
- self.check_post({'step_filler': 'make_full_3'}, '/todo?id=1')
- exp.set_todo_from_post(4, {'process_id': 1})
- exp.set_todo_from_post(3, {'process_id': 2, 'children': [4]})
- exp.set_todo_from_post(2, {'process_id': 3, 'children': [3]})
- exp.set_todo_from_post(1, {'process_id': 4, 'children': [2]})
- step3_proc1 = exp.step_as_dict(3, [], 1, 4, True)
- step2_proc2 = exp.step_as_dict(2, [step3_proc1], 2, 3, True)
- step1_proc3 = exp.step_as_dict(1, [step2_proc2], 3, 2, True)
- exp.set('steps_todo_to_process', [step1_proc3])
- self.check_json_get('/todo?id=1', exp)
- # 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')
- exp.set_todo_from_post(5, {'process_id': 2, 'children': [4]})
- exp.set_todo_from_post(1, {'process_id': 4, 'children': [2, 5]})
- step5_todo4 = exp.step_as_dict(5, [], None, 4)
- step4_todo5 = exp.step_as_dict(4, [step5_todo4], None, 5)
- exp.set('steps_todo_to_process', [step1_proc3, step4_todo5])
- self.check_json_get('/todo?id=1', exp)
- # fail on trying to call make_full on non-existing Process
- self.check_post({'make_full': 5}, '/todo?id=1', 404)
-