diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-28 10:43:51 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-28 10:43:51 +0100 |
| commit | d368de4b30d8a1dc9bb72ba45c55b07d3f034c82 (patch) | |
| tree | 66c586ec73f84f4c30b9d2da4bfa332cc93c7ec0 /tests | |
| parent | 91c87e7dbcb3029d23ce0baa9b2bcab1394381c3 (diff) | |
| download | generat3D-d368de4b30d8a1dc9bb72ba45c55b07d3f034c82.tar.gz generat3D-d368de4b30d8a1dc9bb72ba45c55b07d3f034c82.zip | |
Register figure node formulas after the figure exists
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_scene.py | 23 |
1 files changed, 23 insertions, 0 deletions
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) |
