moo.shell.tests.test_prompt_lifecycle

Tests for the prompt’s REPL lifecycle and inbound event dispatch.

Covers:
  • MooPrompt construction (queues, mode stamping, _chan plumbing)

  • process_commands() dispatch to rich/raw

  • _repl_setup / _repl_teardown lifecycle hooks

  • handle_command() property-write throttling and event-cache draining

  • process_messages() dispatch (paginator + plain tell, raw vs rich)

  • _fire_confunc / _await_tasks login hooks

  • disconnect-event handling

Functions

test_await_tasks_swallows_task_failure()

_await_tasks() does not propagate exceptions so a broken confunc verb cannot block login.

test_await_tasks_waits_for_each_result()

_await_tasks() calls .get() on every task result.

test_disconnect_message_sets_is_exiting()

process_messages() sets is_exiting and fires disconnect_event on a disconnect event.

test_fire_confunc_returns_task_results()

_fire_confunc() returns one AsyncResult per dispatched task.

test_fire_confunc_skips_missing_verbs()

_fire_confunc() returns an empty list when the player has no confunc verbs.

test_handle_command_reads_events_from_cache()

handle_command() returns the event list stashed in the cache under the task id and clears the key.

test_handle_command_throttles_property_writes()

handle_command() skips the property write when fewer than 15 seconds have elapsed.

test_handle_command_writes_after_15_seconds()

handle_command() writes last_connected_time again after more than 15 seconds have elapsed.

test_handle_command_writes_property_on_first_command()

handle_command() writes last_connected_time on the first command (last_property_write is None).

test_init()

MooPrompt initialises with correct default state and async queues.

test_init_raw_mode_stamps_session_settings()

Passing mode=MODE_RAW records the mode in session settings and stores the channel.

test_pre_run_flushes_pending_connect_output_with_osc133()

The pre_run callback flushes _pending_connect_output before the prompt renders, so the on-connect look is visible to the user.

test_pre_run_flushes_pending_connect_output_without_osc133()

Without OSC 133 (e.g. classic MUD clients via IAC), the pending connect output must STILL be flushed — otherwise the room description is silently dropped and the user sees a bare prompt.

test_pre_run_no_pending_output_is_noop()

When there's nothing buffered, pre_run does not write to the output.

test_process_commands_dispatches_to_raw()

process_commands() routes to process_commands_raw when mode is raw.

test_process_commands_dispatches_to_rich()

process_commands() routes to process_commands_rich when mode is rich.

test_process_messages_raw_mode_paginator_dumps_inline()

Paginator events are dumped through writer() without paging in raw mode.

test_process_messages_raw_mode_plain_tell_skips_run_in_terminal()

Plain-message events reach writer() directly without run_in_terminal in raw mode.

test_process_messages_rich_mode_plain_tell_uses_run_in_terminal()

Plain-message events go through run_in_terminal in rich mode.

test_repl_setup_teardown_roundtrip()

_repl_setup() stamps mode and _repl_teardown() clears it, with connect/disconnect fired.