From: Christian Heller Date: Sat, 20 Jul 2024 14:08:10 +0000 (+0200) Subject: Extend Todo doneness POST relations tests. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/error?a=commitdiff_plain;h=80b95d15219c9914d968471f675f145ad216ed79;p=plomtask Extend Todo doneness POST relations tests. --- diff --git a/tests/todos.py b/tests/todos.py index d96741d..89d9a8c 100644 --- a/tests/todos.py +++ b/tests/todos.py @@ -375,9 +375,6 @@ class TestsWithServer(TestCaseWithServer): 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'] = [] @@ -584,6 +581,42 @@ class TestsWithServer(TestCaseWithServer): 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(