"""Tests for deterministic build-step generation.""" from woodshop.instructions import build_steps, format_steps, polish_prompt from woodshop.scene import Scene def _scene(): s = Scene() s.place("2x4", 24) s.rename("p1", "leg") s.add_feature("p1", "tenon", face="end_b", depth_in=1) # f1 s.place("2x4", 48) s.add_feature("p2", "mortise", face="top", along_in=24, width_in=1.5, height_in=1, depth_in=1) # f2 s.connect("f2", "f1") # seat the joint return s def test_steps_cover_the_build_phases(): sections = build_steps(_scene()) titles = [t for t, _ in sections] assert "Gather stock" in titles assert any("Cut pieces" in t for t in titles) assert any("joinery" in t.lower() for t in titles) assert any("glue" in t.lower() for t in titles) # assembly step (has connections) assert titles[-1] == "Finish" def test_steps_carry_real_data(): text = format_steps(build_steps(_scene())) assert "leg" in text # named part appears assert "tenon" in text and "mortise" in text # joinery listed def test_polish_prompt_guards_numbers(): p = polish_prompt(build_steps(_scene())) assert "do not invent" in p.lower() assert "Gather stock" in p def test_empty_scene_still_formats(): assert format_steps(build_steps(Scene()))