"""Tests for rule-based jig suggestions.""" from woodshop.jigs import format_jigs, suggest_jigs from woodshop.scene import Scene def test_repeated_crosscuts_suggest_stop_block(): s = Scene() for _ in range(10): # the canonical example: 10 identical cuts s.place("2x4", 6.5) sb = [j for j in suggest_jigs(s) if j.kind == "stop-block"] assert sb and sb[0].count == 10 assert "6.5" in sb[0].title def test_below_threshold_suggests_nothing(): s = Scene() s.place("2x4", 6.5) s.place("2x4", 6.5) # only 2 < default min_repeats=3 assert suggest_jigs(s) == [] def test_repeated_holes_suggest_drill_template(): s = Scene() for _ in range(4): p = s.place("2x4", 24) s.add_feature(p.id, "hole", face="top", diameter_in=0.375) assert any(j.kind == "drill-template" and j.count == 4 for j in suggest_jigs(s)) def test_repeated_mortises_suggest_template(): s = Scene() for _ in range(3): p = s.place("2x4", 24) s.add_feature(p.id, "mortise", face="top", width_in=1.5, height_in=1, depth_in=1) assert any(j.kind == "mortise-template" for j in suggest_jigs(s)) def test_format_empty(): assert "No repeated" in format_jigs([])