+ def test_Todo_unsatisfied_steps(self) -> None:
+ """Test options of satisfying unfulfilled Process.explicit_steps."""
+ assert isinstance(self.proc.id_, int)
+ todo_1 = Todo(None, self.proc, False, self.date1)
+ todo_1.save(self.db_conn)
+ proc2 = Process(None)
+ proc2.save(self.db_conn)
+ assert isinstance(proc2.id_, int)
+ proc3 = Process(None)
+ proc3.save(self.db_conn)
+ assert isinstance(proc3.id_, int)
+ proc4 = Process(None)
+ proc4.save(self.db_conn)
+ assert isinstance(proc4.id_, int)
+ proc3.set_steps(self.db_conn, [(None, proc4.id_, None)])
+ proc2.set_steps(self.db_conn, [(None, self.proc.id_, None),
+ (None, self.proc.id_, None),
+ (None, proc3.id_, None)])
+ todo_2 = Todo(None, proc2, False, self.date1)
+ todo_2.save(self.db_conn)
+ # test empty adoption does nothing
+ todo_2.adopt_from([])
+ self.assertEqual(todo_2.children, [])
+ # test basic adoption
+ todo_2.adopt_from([todo_1])
+ self.assertEqual(todo_2.children, [todo_1])
+ self.assertEqual(todo_1.parents, [todo_2])
+ # test making missing children
+ todo_2.make_missing_children(self.db_conn)
+ todo_3 = Todo.by_id(self.db_conn, 3)
+ todo_4 = Todo.by_id(self.db_conn, 4)
+ self.assertEqual(todo_2.children, [todo_1, todo_3, todo_4])
+ self.assertEqual(todo_3.process, self.proc)
+ self.assertEqual(todo_3.parents, [todo_2])
+ self.assertEqual(todo_3.children, [])
+ self.assertEqual(todo_4.process, proc3)
+ self.assertEqual(todo_4.parents, [todo_2])
+ # test .make_missing_children doesn't further than top-level
+ self.assertEqual(todo_4.children, [])
+ # test .make_missing_children lower down the tree
+ todo_4.make_missing_children(self.db_conn)
+ todo_5 = Todo.by_id(self.db_conn, 5)
+ self.assertEqual(todo_5.process, proc4)
+ self.assertEqual(todo_4.children, [todo_5])
+ self.assertEqual(todo_5.parents, [todo_4])
+