home · contact · privacy
Rename "condition"/"blocker" input names to plurals, like they are everywhere else.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 21 Jun 2024 01:47:34 +0000 (03:47 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 21 Jun 2024 01:47:34 +0000 (03:47 +0200)
plomtask/http.py
templates/process.html
templates/todo.html
tests/conditions.py
tests/days.py
tests/processes.py

index e1f5434bb2c1fb321a03c7343e022a24652e8978..f3173668492c9badd39cc73d013a7f9229e4e8b2 100644 (file)
@@ -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'))
index 60687d8b96ef3ed9245ccb46671bb346494a6cb9..7bb503eeafd2a68e21987021a7db0a110c4e548b 100644 (file)
@@ -97,11 +97,11 @@ edit process of ID {{process.id_}}
 </tr>
 <tr>
 <th>conditions</th>
-<td>{{ macros.simple_checkbox_table("condition", process.conditions, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("conditions", process.conditions, "condition", "condition_candidates") }}</td>
 </tr>
 <tr>
 <th>blockers</th>
-<td>{{ macros.simple_checkbox_table("blocker", process.blockers, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("blockers", process.blockers, "condition", "condition_candidates") }}</td>
 </tr>
 <tr>
 <th>enables</th>
index c2fb01d710d8d9d0081d70e124f3a38d241ec7e3..fea931ab83ddf57536ab375ce3773a3f656204ce 100644 (file)
@@ -75,11 +75,11 @@ select{ font-size: 0.5em; margin: 0; padding: 0; }
 </tr>
 <tr>
 <th>conditions</th>
-<td>{{ macros.simple_checkbox_table("condition", todo.conditions, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("conditions", todo.conditions, "condition", "condition_candidates") }}</td>
 </tr>
 <tr>
 <th>blockers</th>
-<td>{{ macros.simple_checkbox_table("blocker", todo.blockers, "condition", "condition_candidates") }}</td>
+<td>{{ macros.simple_checkbox_table("blockers", todo.blockers, "condition", "condition_candidates") }}</td>
 </tr>
 <tr>
 <th>enables</th>
index 198df5f70bbf28618558967cdccdd52f8224e007..8f86854f16f0c47aa676b7b9b3ce07b49660c107 100644 (file)
@@ -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])
index 5c910ecdb9cf639c44ed6e0492aaae1190a20f65..59c9f4911b8d6b649d42cb71a9035c811af7e1df 100644 (file)
@@ -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)
index 5c3e70364d32b679a339b9ac9ed591ad3295e365..9e266e017aab0abb23717e8550f98e31c9b5fe15 100644 (file)
@@ -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'] = ''