From d368de4b30d8a1dc9bb72ba45c55b07d3f034c82 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 28 Oct 2026 10:43:51 +0100 Subject: Register figure node formulas after the figure exists Co-Authored-By: Claude Sonnet 5.5 --- tests/test_scene.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/test_scene.py b/tests/test_scene.py index 6ea7fa3..76a28b6 100644 --- a/tests/test_scene.py +++ b/tests/test_scene.py @@ -210,3 +210,26 @@ class SceneTest(unittest.TestCase): def test_follower_modifier_not_reported_missing(self): load_quiet(self.duf({"nodes": self.base_nodes(), "modifiers": [ self.tall("#Shirt", 1, "/data/Test/Shirt/Shirt.dsf#Loose")]})) + + def fig_doc(self, hip_extra=None, verts=None): + """A figure file with root Fig2 and a bone hip (id), optionally tweaked.""" + xyz = lambda *v: [{"id": a, "value": x} for a, x in zip("xyz", v)] + hip = {"id": "hip", "name": "hip", "type": "bone", "center_point": xyz(0, 5, 0), + "end_point": xyz(0, 8, 0), "orientation": xyz(0, 0, 0)} + hip.update(hip_extra or {}) + root = {"id": "Fig2", "name": "Fig2", "type": "figure", "center_point": xyz(0, 0, 0), + "end_point": xyz(0, 10, 0), "orientation": xyz(0, 0, 0)} + return {"node_library": [root, hip], "geometry_library": [ + {"id": "g", "vertices": {"values": verts or [[0, 0, 0], [1, 0, 0], [0, 1, 0]]}}]} + + def fig2(self, **kw): + """Load a scene of the temp figure; returns (scene, stderr).""" + root = self.root("data/Test/Fig2/Fig2.dsf", self.fig_doc(**kw)) + nodes = [{"id": "Fig2", "url": "/data/Test/Fig2/Fig2.dsf#Fig2", "name": "Fig2"}] + return load_quiet(self.duf({"nodes": nodes}), [root]) + + def test_figure_node_formulas_registered(self): + scene, _ = self.fig2(hip_extra={"formulas": [{ + "output": "hip:/data/Test/Fig2/Fig2.dsf#hip?center_point/y", + "operations": [{"op": "push", "val": 1}]}]}) + self.assertEqual(len(scene.graph.formulas["hip:hip?center_point/y"]), 1) -- cgit v1.2.3