@@ -158,6 +158,35 @@ def _wait(_interval: int) -> bool:
158158 assert mgr .cleanup_called == 0
159159
160160
161+ @pytest .mark .parametrize (
162+ "pressure, min_pressure, max_pressure, expected" ,
163+ [
164+ pytest .param (5 , 0 , 10 , 5 , id = "within_bounds" ),
165+ pytest .param (15 , 0 , 10 , 10 , id = "clamped_to_max" ),
166+ pytest .param (1 , 3 , 10 , 3 , id = "raised_to_min" ),
167+ pytest .param (15 , 3 , 10 , 10 , id = "max_wins_over_pressure" ),
168+ pytest .param (5 , 0 , 0 , 5 , id = "zero_max_means_no_cap" ),
169+ pytest .param (- 1 , 0 , 0 , 0 , id = "negative_clamped_to_zero" ),
170+ ],
171+ )
172+ def test_desired_total_from_pressure_respects_bounds (
173+ pressure : int , min_pressure : int , max_pressure : int , expected : int
174+ ):
175+ """
176+ arrange: A reconciler with various min/max pressure configurations.
177+ act: Call _desired_total_from_pressure.
178+ assert: The result is clamped within the configured bounds.
179+ """
180+ mgr = _FakeManager ()
181+ planner = _FakePlanner ()
182+ cfg = PressureReconcilerConfig (
183+ flavor_name = "small" , min_pressure = min_pressure , max_pressure = max_pressure
184+ )
185+ reconciler = PressureReconciler (mgr , planner , cfg , lock = Lock ())
186+
187+ assert reconciler ._desired_total_from_pressure (pressure ) == expected
188+
189+
161190def test_handle_timer_reconcile_uses_desired_total_not_raw_pressure ():
162191 """
163192 arrange: A reconciler with 4 runners and min_pressure=5.
0 commit comments