moo.shell.tests.test_prompt_sessions

Tests for the prompt’s interactive sub-sessions.

Covers:
  • the GMCP Editor.Start handoff path (_try_gmcp_editor_handoff) and how _route_event chooses between handoff and the prompt-toolkit fallback

  • run_editor_session callback dispatch (wizard-only, cancellation, missing callback fields)

  • run_paginator_session

  • the raw-mode editor rejection text

  • run_input_session: chained password prompts and timeout exit

Functions

test_gmcp_editor_handoff_noop_when_user_missing()

No user → no handoff.

test_gmcp_editor_handoff_rolls_back_pending_on_send_failure()

If writing the Editor.Start frame raises, the pending entry is removed so a future Editor.Save from a stale id cannot dispatch a callback that the client never actually started.

test_gmcp_editor_handoff_skipped_when_editor_package_not_advertised()

A client that never sent Core.Supports.Set [Editor 1] falls through to the TUI editor.

test_gmcp_editor_handoff_writes_editor_start_and_stashes_pending()

Successful handoff: the GMCP Editor.Start frame goes to the channel, the callback metadata is stashed under the generated edit id, and the return value tells the caller to NOT also enqueue the prompt-toolkit fallback.

test_raw_editor_event_emits_rejection_text()

An editor request in raw mode is refused with the inline-form hint.

test_route_event_editor_falls_back_to_queue_when_no_gmcp_bridge()

When the GMCP handoff returns False (no bridge), _route_event must push the editor message onto the queue so the prompt-toolkit TUI editor can pick it up — the existing behaviour for vanilla SSH clients.

test_route_event_editor_returns_early_when_gmcp_handoff_succeeds()

When _try_gmcp_editor_handoff reports success, _route_event must NOT also enqueue the editor message — otherwise the prompt-toolkit TUI would open over top of the bridge editor.

test_run_editor_session_invokes_callback()

run_editor_session() calls invoke_verb.delay when editor returns text and callback fields are set.

test_run_editor_session_no_invoke_when_cancelled()

run_editor_session() does not call invoke_verb.delay when the user cancels (run_editor returns None).

test_run_editor_session_no_invoke_without_callback()

run_editor_session() does not call invoke_verb.delay when callback fields are absent.

test_run_editor_session_rejects_non_wizard_caller_id()

run_editor_session() must not invoke the callback when caller_id is not a wizard (forged event guard).

test_run_input_session_consumes_chain_without_prompt()

run_input_session() drains sequential input_prompt events from input_queue in a single call.

test_run_input_session_exits_when_queue_times_out()

run_input_session() returns after a timeout once no further input_prompt events arrive.

test_run_paginator_session()

run_paginator_session() delegates to run_paginator with content and content_type.