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
_await_tasks() does not propagate exceptions so a broken confunc verb cannot block login. |
|
_await_tasks() calls .get() on every task result. |
|
process_messages() sets is_exiting and fires disconnect_event on a disconnect event. |
|
_fire_confunc() returns one AsyncResult per dispatched task. |
|
_fire_confunc() returns an empty list when the player has no confunc verbs. |
|
handle_command() returns the event list stashed in the cache under the task id and clears the key. |
|
handle_command() skips the property write when fewer than 15 seconds have elapsed. |
|
handle_command() writes last_connected_time again after more than 15 seconds have elapsed. |
|
handle_command() writes last_connected_time on the first command (last_property_write is None). |
|
MooPrompt initialises with correct default state and async queues. |
|
Passing mode=MODE_RAW records the mode in session settings and stores the channel. |
|
The pre_run callback flushes _pending_connect_output before the prompt renders, so the on-connect look is visible to the user. |
|
|
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. |
When there's nothing buffered, pre_run does not write to the output. |
|
process_commands() routes to process_commands_raw when mode is raw. |
|
process_commands() routes to process_commands_rich when mode is rich. |
|
Paginator events are dumped through writer() without paging in raw mode. |
|
|
Plain-message events reach writer() directly without run_in_terminal in raw mode. |
|
Plain-message events go through run_in_terminal in rich mode. |
_repl_setup() stamps mode and _repl_teardown() clears it, with connect/disconnect fired. |