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'] = []
expected['adoption_candidates_for'] = {'2': [], '3': [], '4': []}
self.check_json_get('/todo?id=1', expected)
+ def test_do_POST_doneness_relations(self) -> None:
+ """Test Todo.is_done Condition, adoption relations for /todo POSTs."""
+ # test Todo with adoptee can only be set done if adoptee is done too
+ self._make_todo_via_day_post(1)
+ self._make_todo_via_day_post(1)
+ self.check_post({'adopt': 2, 'done': ''}, '/todo?id=1', 400)
+ self.check_post({'done': ''}, '/todo?id=2')
+ self.check_post({'adopt': 2, 'done': ''}, '/todo?id=1', 302)
+ # test Todo cannot be set undone with adopted Todo not done yet
+ self.check_post({}, '/todo?id=2')
+ self.check_post({'adopt': 2}, '/todo?id=1', 400)
+ # test unadoption relieves block
+ self.check_post({}, '/todo?id=1', 302)
+ # test Condition being set or unset can block doneness setting
+ c1_post = {'title': '', 'description': '', 'is_active': False}
+ c2_post = {'title': '', 'description': '', 'is_active': True}
+ self.check_post(c1_post, '/condition', redir='/condition?id=1')
+ self.check_post(c2_post, '/condition', redir='/condition?id=2')
+ self.check_post({'conditions': [1], 'done': ''}, '/todo?id=1', 400)
+ self.check_post({'done': ''}, '/todo?id=1', 302)
+ self.check_post({'blockers': [2]}, '/todo?id=1', 400)
+ self.check_post({'done': ''}, '/todo?id=1', 302)
+ # test setting Todo doneness can set/un-set Conditions, but only on
+ # doneness change, not by mere passive state
+ self.check_post({'enables': [1], 'done': ''}, '/todo?id=1')
+ self.check_post({'conditions': [1], 'done': ''}, '/todo?id=2', 400)
+ self.check_post({'enables': [1]}, '/todo?id=1')
+ self.check_post({'enables': [1], 'done': ''}, '/todo?id=1')
+ self.check_post({'conditions': [1], 'done': ''}, '/todo?id=2')
+ self.check_post({'blockers': [1]}, '/todo?id=2', 400)
+ self.check_post({'disables': [1], 'done': ''}, '/todo?id=1')
+ self.check_post({'blockers': [1]}, '/todo?id=2', 400)
+ self.check_post({'disables': [1]}, '/todo?id=1')
+ self.check_post({'disables': [1], 'done': ''}, '/todo?id=1')
+ self.check_post({'blockers': [1]}, '/todo?id=2')
+
def test_do_POST_day_todo_adoption(self) -> None:
"""Test Todos posted to Day view may adopt existing Todos."""
form_data = self.post_process(