test_setup_prompt_menus.py
1 from hermes_cli import setup as setup_mod 2 3 4 def test_prompt_choice_uses_curses_helper(monkeypatch): 5 monkeypatch.setattr(setup_mod, "_curses_prompt_choice", lambda question, choices, default=0, description=None: 1) 6 7 idx = setup_mod.prompt_choice("Pick one", ["a", "b", "c"], default=0) 8 9 assert idx == 1 10 11 12 def test_prompt_choice_falls_back_to_numbered_input(monkeypatch): 13 monkeypatch.setattr(setup_mod, "_curses_prompt_choice", lambda question, choices, default=0, description=None: -1) 14 monkeypatch.setattr("builtins.input", lambda _prompt="": "2") 15 16 idx = setup_mod.prompt_choice("Pick one", ["a", "b", "c"], default=0) 17 18 assert idx == 1 19 20 21 def test_prompt_checklist_uses_shared_curses_checklist(monkeypatch): 22 monkeypatch.setattr( 23 "hermes_cli.curses_ui.curses_checklist", 24 lambda title, items, selected, cancel_returns=None: {0, 2}, 25 ) 26 27 selected = setup_mod.prompt_checklist("Pick tools", ["one", "two", "three"], pre_selected=[1]) 28 29 assert selected == [0, 2]