home · contact · privacy
Minor fixes of freshly introduced bugs.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 5 Aug 2024 05:57:34 +0000 (07:57 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 5 Aug 2024 05:57:34 +0000 (07:57 +0200)
plomtask/processes.py
plomtask/todos.py
tests/processes.py

index b68ffd8ecb3f2df8e25c46b9558879cb9dbea5fb..56dd282acce8147d24b502cc61c81862765e9359 100644 (file)
@@ -14,11 +14,13 @@ class ProcessStepsNode(DictableNode):
     """Collects what's useful to know for ProcessSteps tree display."""
     # pylint: disable=too-few-public-methods
     step: ProcessStep
+    process: Process
     is_explicit: bool
     steps: list[ProcessStepsNode]
     seen: bool = False
     is_suppressed: bool = False
-    _to_dict = ['step', 'is_explicit', 'steps', 'seen', 'is_suppressed']
+    _to_dict = ['step', 'process', 'is_explicit', 'steps', 'seen',
+                'is_suppressed']
 
 
 class Process(BaseModel[int], ConditionsRelations):
@@ -98,8 +100,8 @@ class Process(BaseModel[int], ConditionsRelations):
             step_steps = []
             if not suppressed:
                 step_steps = process.get_steps(db_conn, external_owner)
-            return ProcessStepsNode(step, is_explicit, step_steps, False,
-                                    suppressed)
+            return ProcessStepsNode(step, process, is_explicit, step_steps,
+                                    False, suppressed)
 
         def walk_steps(node: ProcessStepsNode) -> None:
             node.seen = node.step.id_ in seen_step_ids
index 32911078369ada1e85c6a96fade5d3b58661e82a..9f9fdb4aadb3c9912b258453dbe507e96f6c4503 100644 (file)
@@ -94,26 +94,24 @@ class Todo(BaseModel[int], ConditionsRelations):
             adoptables = [t for t in Todo.by_date(db_conn, parent.date)
                           if (t not in parent.children)
                           and (t != parent)
-                          and step_node.step.step_process_id == t.process.id_]
+                          and step_node.process.id_ == t.process_id]
             satisfier = None
             for adoptable in adoptables:
                 satisfier = adoptable
                 break
             if not satisfier:
-                proc = Process.by_id(db_conn, step_node.step.step_process_id)
-                satisfier = Todo(None, proc, False, parent.date)
+                satisfier = Todo(None, step_node.process, False, parent.date)
                 satisfier.save(db_conn)
-            sub_step_nodes = sorted(step_node.steps,
-                                    key=lambda s: s.step.step_process_id)
+            sub_step_nodes = sorted(
+                    step_node.steps,
+                    key=lambda s: s.process.id_ if s.process.id_ else 0)
             for sub_node in sub_step_nodes:
                 if sub_node.is_suppressed:
                     continue
                 n_slots = len([n for n in sub_step_nodes
-                               if n.step.step_process_id
-                               == sub_node.step.step_process_id])
+                               if n.process == sub_node.process])
                 filled_slots = len([t for t in satisfier.children
-                                    if t.process.id_
-                                    == sub_node.step.step_process_id_])
+                                    if t.process.id_ == sub_node.process.id_])
                 # if we did not newly create satisfier, it may already fill
                 # some step dependencies, so only fill what remains open
                 if n_slots - filled_slots > 0:
index 9affa8430eaec198c858560a9065e837aeb5d258..6f2dc42178564e6e251d964db12b3d9cb5a8f2e9 100644 (file)
@@ -252,12 +252,15 @@ class ExpectedGetProcess(Expected):
 
     @staticmethod
     def stepnode_as_dict(step_id: int,
+                         proc_id: int,
                          seen: bool = False,
                          steps: None | list[dict[str, object]] = None,
                          is_explicit: bool = True,
                          is_suppressed: bool = False) -> dict[str, object]:
+        # pylint: disable=too-many-arguments
         """Return JSON of ProcessStepNode to expect."""
         return {'step': step_id,
+                'process': proc_id,
                 'seen': seen,
                 'steps': steps if steps else [],
                 'is_explicit': is_explicit,
@@ -352,7 +355,7 @@ class TestsWithServer(TestCaseWithServer):
         # post first (top-level) step of proc 2 to proc 1 by 'step_of' in 2
         self.post_exp_process([exp], {'step_of': 1}, 2)
         exp.lib_set('ProcessStep', [exp.procstep_as_dict(1, 1, 2)])
-        exp.set('steps', [exp.stepnode_as_dict(1)])
+        exp.set('steps', [exp.stepnode_as_dict(1, 2)])
         self.check_json_get(url, exp)
         # post empty/absent steps list to process, expect clean slate, and old
         # step to completely disappear
@@ -364,7 +367,7 @@ class TestsWithServer(TestCaseWithServer):
         self.post_exp_process([exp], {'new_top_step': 2}, 1)
         exp.lib_set('ProcessStep', [exp.procstep_as_dict(1, 1, 2)])
         self.post_exp_process([exp], {'kept_steps': [1]}, 1)
-        exp.set('steps', [exp.stepnode_as_dict(1)])
+        exp.set('steps', [exp.stepnode_as_dict(1, 2)])
         self.check_json_get(url, exp)
         # fail on single- and multi-step recursion
         p_min = {'title': '', 'description': '', 'effort': 0}
@@ -381,15 +384,16 @@ class TestsWithServer(TestCaseWithServer):
         self.post_exp_process([exp], {'kept_steps': [1], 'new_top_step': 4}, 1)
         exp.lib_set('ProcessStep', [exp.procstep_as_dict(1, 1, 4),
                                     exp.procstep_as_dict(2, 1, 4)])
-        exp.set('steps', [exp.stepnode_as_dict(1), exp.stepnode_as_dict(2)])
+        exp.set('steps', [exp.stepnode_as_dict(1, 4),
+                          exp.stepnode_as_dict(2, 4)])
         self.check_json_get(url, exp)
         # post sub-step chain
         p = {'kept_steps': [1, 2], 'new_step_to_2': 4}
         self.post_exp_process([exp], p, 1)
         exp.lib_set('ProcessStep', [exp.procstep_as_dict(3, 1, 4, 2)])
-        exp.set('steps', [exp.stepnode_as_dict(1),
-                          exp.stepnode_as_dict(2, steps=[
-                              exp.stepnode_as_dict(3)])])
+        exp.set('steps', [exp.stepnode_as_dict(1, 4),
+                          exp.stepnode_as_dict(2, 4, steps=[
+                              exp.stepnode_as_dict(3, 4)])])
         self.check_json_get(url, exp)
         # fail posting sub-step that would cause recursion
         self.post_exp_process([exp], {}, 6)