[pather / planner] pass planner options via plan_options, not strategy/bend_policy

This commit is contained in:
Jan Petykiewicz 2026-08-27 10:52:43 -07:00
commit ce7463e57c
8 changed files with 280 additions and 115 deletions

View file

@ -986,6 +986,16 @@ def test_routing_entry_points_have_no_catch_all_kwargs(route_type: type, name: s
assert all(parameter.kind is not inspect.Parameter.VAR_KEYWORD for parameter in parameters)
@pytest.mark.parametrize('route_type', [Pather, PortPather])
@pytest.mark.parametrize('name', ['trace', 'trace_to', 'straight', 'bend', 'ccw', 'cw', 'jog', 'uturn', 'trace_into'])
def test_routing_entry_points_use_generic_plan_options(route_type: type, name: str) -> None:
parameters = inspect.signature(getattr(route_type, name)).parameters
assert 'plan_options' in parameters
assert 'strategy' not in parameters
assert 'bend_policy' not in parameters
def test_routing_typo_fails_before_tool_lookup() -> None:
tool = RequestCountingTool()
p = Pather(Library(), tools=tool, render='deferred')
@ -1007,6 +1017,41 @@ def test_tool_options_reject_invalid_or_reserved_keys(tool_options: dict[Any, An
assert tool.offer_calls == 0
@pytest.mark.parametrize('plan_options', [7, {1: 'bad'}])
def test_plan_options_reject_invalid_mapping_shape(plan_options: Any) -> None:
tool = RequestCountingTool()
p = Pather(Library(), tools=tool, render='deferred')
with pytest.raises(BuildError, match='plan_options'):
p.trace('A', None, plan_options=plan_options)
assert tool.offer_calls == 0
@pytest.mark.parametrize(
'plan_options',
[
{'bend_policy': 'flexible'},
{'unknown': True},
],
)
def test_default_planner_rejects_unsupported_plan_options_before_tool_lookup(
plan_options: dict[str, Any],
) -> None:
tool = RequestCountingTool()
p = Pather(
Library(),
ports={'A': Port((0, 0), rotation=0, ptype='wire')},
tools=tool,
render='deferred',
)
with pytest.raises(BuildError, match='unsupported keys'):
p.trace('A', None, length=1, plan_options=plan_options)
assert tool.offer_calls == 0
@pytest.mark.parametrize(
'operation',
[