From: Christian Heller Date: Fri, 21 Jun 2024 01:47:34 +0000 (+0200) Subject: Rename "condition"/"blocker" input names to plurals, like they are everywhere else. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/edit?a=commitdiff_plain;h=1a9557367351fe26d08ea705400b3b56394caae6;p=plomtask Rename "condition"/"blocker" input names to plurals, like they are everywhere else. --- diff --git a/plomtask/http.py b/plomtask/http.py index e1f5434..f317366 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -580,8 +580,8 @@ class TaskHandler(BaseHTTPRequestHandler): effort = self._form_data.get_str('effort', ignore_strict=True) todo.effort = float(effort) if effort else None todo.set_conditions(self.conn, - self._form_data.get_all_int('condition')) - todo.set_blockers(self.conn, self._form_data.get_all_int('blocker')) + self._form_data.get_all_int('conditions')) + todo.set_blockers(self.conn, self._form_data.get_all_int('blockers')) todo.set_enables(self.conn, self._form_data.get_all_int('enables')) todo.set_disables(self.conn, self._form_data.get_all_int('disables')) todo.is_done = len(self._form_data.get_all_str('done')) > 0 @@ -617,8 +617,9 @@ class TaskHandler(BaseHTTPRequestHandler): process.description.set(self._form_data.get_str('description')) process.effort.set(self._form_data.get_float('effort')) process.set_conditions(self.conn, - self._form_data.get_all_int('condition')) - process.set_blockers(self.conn, self._form_data.get_all_int('blocker')) + self._form_data.get_all_int('conditions')) + process.set_blockers(self.conn, + self._form_data.get_all_int('blockers')) process.set_enables(self.conn, self._form_data.get_all_int('enables')) process.set_disables(self.conn, self._form_data.get_all_int('disables')) diff --git a/templates/process.html b/templates/process.html index 60687d8..7bb503e 100644 --- a/templates/process.html +++ b/templates/process.html @@ -97,11 +97,11 @@ edit process of ID {{process.id_}} conditions -{{ macros.simple_checkbox_table("condition", process.conditions, "condition", "condition_candidates") }} +{{ macros.simple_checkbox_table("conditions", process.conditions, "condition", "condition_candidates") }} blockers -{{ macros.simple_checkbox_table("blocker", process.blockers, "condition", "condition_candidates") }} +{{ macros.simple_checkbox_table("blockers", process.blockers, "condition", "condition_candidates") }} enables diff --git a/templates/todo.html b/templates/todo.html index c2fb01d..fea931a 100644 --- a/templates/todo.html +++ b/templates/todo.html @@ -75,11 +75,11 @@ select{ font-size: 0.5em; margin: 0; padding: 0; } conditions -{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates") }} +{{ macros.simple_checkbox_table("conditions", todo.conditions, "condition", "condition_candidates") }} blockers -{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates") }} +{{ macros.simple_checkbox_table("blockers", todo.blockers, "condition", "condition_candidates") }} enables diff --git a/tests/conditions.py b/tests/conditions.py index 198df5f..8f86854 100644 --- a/tests/conditions.py +++ b/tests/conditions.py @@ -96,10 +96,10 @@ class TestsWithServer(TestCaseWithServer): form_data = {'title': 'foo', 'description': 'oof', 'is_active': False} self.check_post(form_data, '/condition', 302, '/condition?id=1') proc_1_post = {'title': 'A', 'description': '', 'effort': 1.0, - 'condition': [1], 'disables': [1]} + 'conditions': [1], 'disables': [1]} self.post_process(1, proc_1_post) proc_2_post = {'title': 'B', 'description': '', 'effort': 1.0, - 'enables': [1], 'blocker': [1]} + 'enables': [1], 'blockers': [1]} self.post_process(2, proc_2_post) cond = self.cond_as_dict(titles=['foo'], descriptions=['oof']) proc_1 = self.proc_as_dict(conditions=[cond], disables=[cond]) diff --git a/tests/days.py b/tests/days.py index 5c910ec..59c9f49 100644 --- a/tests/days.py +++ b/tests/days.py @@ -124,7 +124,7 @@ class TestsWithServer(TestCaseWithServer): '_library': {'Day': TestsWithServer.as_refs([day])}} return d - def post_day(self, params: str, + def post_day(self, params: str = '', form_data: None | dict[str, object] = None, redir_to: str = '', status: int = 302, @@ -163,35 +163,42 @@ class TestsWithServer(TestCaseWithServer): day = expected['_library']['Day'][date] day['comment'] = post['day_comment'] self.check_json_get(f'/day?date={date}', expected) - # check GET parameter of a POST does not affect reply to param-free GET + # check GET parameter to GET requests affects immediate reply, but … + expected['make_type'] = 'bar' + self.check_json_get(f'/day?date={date}&make_type=bar', expected) + # … not any following, … + expected['make_type'] = '' + self.check_json_get(f'/day?date={date}', expected) + # … not even when part of a POST request post['make_type'] = 'foo' self.post_day(f'date={date}', post) self.check_json_get(f'/day?date={date}', expected) - expected['make_type'] = 'bar' - self.check_json_get(f'/day?date={date}&make_type=bar', expected) - def test_do_GET_day_with_todos_flat(self) -> None: - """Test GET /day displaying posted Todos (no tree structure).""" - # post two Todos of differing processes and check their display + def test_do_GET_day_with_processes_and_todos(self) -> None: + """Test GET /day displaying Processes and Todos.""" date = '2024-01-01' - self.post_day(f'date={date}') - expected = self.get_day_dict(date) + # check Processes get displayed in ['processes'] and ['_library'] post_proc1 = {'title': 'foo', 'description': 'oof', 'effort': 1.1} post_proc2 = {'title': 'bar', 'description': 'rab', 'effort': 0.9} - procs: list[dict[str, object]] = [{}, {}] + procs_expected: list[dict[str, object]] = [{}, {}] for i, post in enumerate([post_proc1, post_proc2]): self.post_process(i+1, post) assert isinstance(post['title'], str) assert isinstance(post['description'], str) assert isinstance(post['effort'], float) - procs[i] = self.proc_as_dict(i+1, post['title'], - post['description'], post['effort']) + procs_expected[i] = self.proc_as_dict(i+1, post['title'], + post['description'], + post['effort']) + self.post_day(f'date={date}') + expected = self.get_day_dict(date) + expected['processes'] = self.as_id_list(procs_expected) + assert isinstance(expected['_library'], dict) + expected['_library']['Process'] = self.as_refs(procs_expected) + self.check_json_get(f'/day?date={date}', expected) + # post Todos of either process and check their display post_day: dict[str, object] post_day = {'day_comment': '', 'make_type': '', 'new_todo': [1, 2]} self.post_day(f'date={date}', post_day) - assert isinstance(expected['_library'], dict) - expected['_library']['Process'] = self.as_refs(procs) - expected['processes'] = self.as_id_list(procs) todos = [self.todo_as_dict(1, 1, date), self.todo_as_dict(2, 2, date)] expected['_library']['Todo'] = self.as_refs(todos) expected['_library']['Day'][date]['todos'] = self.as_id_list(todos) @@ -228,8 +235,7 @@ class TestsWithServer(TestCaseWithServer): post_proc1 = {'title': 'foo', 'description': 'oof', 'effort': 1.1} post_proc2 = {'title': 'bar', 'description': 'rab', 'effort': 0.9} procs: list[dict[str, object]] = [{}, {}] - names_input = ('condition', 'disables', 'blocker', 'enables') - names_output = ('conditions', 'disables', 'blockers', 'enables') + cond_names = ('conditions', 'disables', 'blockers', 'enables') cond_vals = ((1, 1, 2, 2), (2, 2, 1, 1)) for i, post in enumerate([post_proc1, post_proc2]): assert isinstance(post['title'], str) @@ -237,9 +243,9 @@ class TestsWithServer(TestCaseWithServer): assert isinstance(post['effort'], float) procs[i] = self.proc_as_dict(i+1, post['title'], post['description'], post['effort']) - for j, name_input in enumerate(names_input): - post[name_input] = [cond_vals[i][j]] - procs[i][names_output[j]] = [cond_vals[i][j]] + for j, cond_name in enumerate(cond_names): + post[cond_name] = [cond_vals[i][j]] + procs[i][cond_name] = [cond_vals[i][j]] self.post_process(i+1, post) date = '2024-01-01' expected = self.get_day_dict(date) diff --git a/tests/processes.py b/tests/processes.py index 5c3e703..9e266e0 100644 --- a/tests/processes.py +++ b/tests/processes.py @@ -251,12 +251,12 @@ class TestsWithServer(TestCaseWithServer): '/process?id=', 400) self.assertEqual(1, len(Process.all(self.db_conn))) form_data = {'title': 'foo', 'description': 'foo', 'effort': 1.0} - self.post_process(2, form_data | {'condition': []}) - self.check_post(form_data | {'condition': [1]}, '/process?id=', 404) + self.post_process(2, form_data | {'conditions': []}) + self.check_post(form_data | {'conditions': [1]}, '/process?id=', 404) self.check_post({'title': 'foo', 'description': 'foo', 'is_active': False}, '/condition', 302, '/condition?id=1') - self.post_process(3, form_data | {'condition': [1]}) + self.post_process(3, form_data | {'conditions': [1]}) self.post_process(4, form_data | {'disables': [1]}) self.post_process(5, form_data | {'enables': [1]}) form_data['delete'] = ''