@@ -323,6 +323,76 @@ def test_iter_notifications_survives_overflow(
323323 assert first .kind .name == "SESSIONS_CHANGED"
324324
325325
326+ class SetClientFlagsCase (t .NamedTuple ):
327+ """Fixture for refresh-client flag construction."""
328+
329+ test_id : str
330+ kwargs : dict [str , t .Any ]
331+ expected_flags : set [str ]
332+ expect_run : bool
333+
334+
335+ @pytest .mark .parametrize (
336+ "case" ,
337+ [
338+ SetClientFlagsCase (
339+ test_id = "enable_no_output_with_pause" ,
340+ kwargs = {"no_output" : True , "pause_after" : 1 },
341+ expected_flags = {"no-output" , "pause-after=1" },
342+ expect_run = True ,
343+ ),
344+ SetClientFlagsCase (
345+ test_id = "disable_no_output_clear_pause" ,
346+ kwargs = {"no_output" : False , "pause_after" : 0 },
347+ expected_flags = {"no-output=off" , "pause-after=none" },
348+ expect_run = True ,
349+ ),
350+ SetClientFlagsCase (
351+ test_id = "noop_when_no_flags" ,
352+ kwargs = {},
353+ expected_flags = set (),
354+ expect_run = False ,
355+ ),
356+ ],
357+ ids = lambda c : c .test_id ,
358+ )
359+ def test_set_client_flags_builds_refresh_client (case : SetClientFlagsCase ) -> None :
360+ """set_client_flags should call refresh-client with correct flag string."""
361+ engine = ControlModeEngine (start_threads = False )
362+ calls : list [tuple [str , tuple [str , ...], tuple [str , ...]]] = []
363+
364+ class DummyCmd :
365+ stdout : list [str ] = []
366+ stderr : list [str ] = []
367+ returncode = 0
368+
369+ def fake_run (
370+ cmd : str ,
371+ cmd_args : t .Sequence [str | int ] | None = None ,
372+ server_args : t .Sequence [str | int ] | None = None ,
373+ timeout : float | None = None ,
374+ ) -> DummyCmd : # type: ignore[override]
375+ calls .append ((cmd , tuple (cmd_args or ()), tuple (server_args or ())))
376+ return DummyCmd ()
377+
378+ engine .run = fake_run # type: ignore[assignment]
379+
380+ engine .set_client_flags (** case .kwargs )
381+
382+ if not case .expect_run :
383+ assert calls == []
384+ return
385+
386+ assert len (calls ) == 1
387+ cmd , cmd_args , server_args = calls [0 ]
388+ assert cmd == "refresh-client"
389+ assert cmd_args and cmd_args [0 ] == "-f"
390+ flags_str = cmd_args [1 ] if len (cmd_args ) > 1 else ""
391+ for flag in case .expected_flags :
392+ assert flag in flags_str
393+ assert server_args == ()
394+
395+
326396class ScriptedStdin :
327397 """Fake stdin that can optionally raise BrokenPipeError on write."""
328398
0 commit comments