moo.shell.tests.test_session_commands

Tests for shell-layer session control features.

Covers: - TERM detection in MooPromptToolkitSSHSession.session_started() - Session setting registry updates via process_messages() - Global output prefix/suffix wrapping in handle_command() and process_messages() - .flush / _drain_messages()

Functions

test_drain_messages_processes_session_settings()

_drain_messages() applies session_setting events it encounters while draining.

test_drain_messages_writes_pending_text()

_drain_messages() returns each plain text message in the queue.

test_editor_rejection_includes_error_prefix_when_prefixes_on()

_editor_rejection_pieces wraps the message with [ERROR] when prefixes_mode is True.

test_editor_rejection_omits_error_prefix_when_prefixes_off()

_editor_rejection_pieces does NOT add [ERROR] when prefixes_mode is False (default).

test_flush_command_calls_drain_messages()

process_commands() routes '.flush' to _drain_messages, not handle_command.

test_handle_command_emits_global_prefix_and_suffix()

handle_command() wraps output with output_global_prefix and output_global_suffix.

test_handle_command_global_markers_are_outermost()

When PREFIX/SUFFIX and global markers are both set, global markers are outermost.

test_handle_command_skips_osc133_when_disabled()

handle_command() omits OSC 133 wrappers when osc133_mode is False.

test_handle_command_wraps_with_exit_status_one_on_error()

handle_command() emits OSC 133;D;1 when parse_command reports exit_status=1.

test_handle_command_wraps_with_osc133_by_default()

handle_command() prepends OSC 133;C and appends ;D;0 when osc133 is on (default).

test_osc133_default_on()

The osc133 accessor defaults to True when no setting is recorded.

test_osc133_disabled_when_set_false()

The osc133 accessor honours an explicit False setting.

test_plain_message_wrapped_with_global_prefix_suffix()

process_messages() wraps a plain text message with output_global_prefix/suffix.

test_repl_setup_signals_startup_drain_complete()

_repl_setup must open the session buffer, fire confunc, and signal process_messages that startup has finished.

test_session_setting_message_updates_registry()

process_messages() stores a session_setting event in _session_settings.

test_session_started_default_term_keeps_cpr_enabled()

A vanilla terminal type produces a rich session with CPR untouched.

test_session_started_legacy_moo_automation_term_no_longer_special_cased()

The retired moo-automation TERM is treated as any other unknown terminal.

test_session_started_no_channel()

session_started() with _chan=None does not crash.

test_startup_opens_session_buffer_before_firing_confunc()

Regression: _repl_setup must open the player's Kombu consumer BEFORE dispatching confunc tasks, otherwise the room's tell() messages are published to the exchange while no queue exists (queues bind with auto_delete=True) and get silently dropped.

test_writer_emits_raw_ansi_to_chan_in_raw_mode()

writer() with a _RawAnsi argument writes the raw bytes to the channel without LF translation.