moo.agent.tests.test_connection

Tests for moo/agent/connection.py.

No real SSH connection — tests MooSession in isolation by calling data_received directly. Does not require DJANGO_SETTINGS_MODULE.

Functions

test_completes_ttype_handshake_in_three_stages()

test_connection_lost_fires_disconnect_callback()

test_connection_lost_no_callback_is_safe()

test_connection_made_sets_surrogateescape_encoding()

test_delimiter_mode_captures_multiple_tell_messages()

test_delimiter_mode_does_not_emit_partial_line_eagerly()

test_delimiter_mode_drops_inline_prompt_before_prefix()

In raw mode the server emits its colored prompt (e.g. >>> `) on the same wire line as the next OUTPUTPREFIX marker — there is no `n between the prompt and the prefix.

test_delimiter_mode_eagerly_flushes_complete_lines()

test_delimiter_mode_emits_preamble_before_prefix()

test_delimiter_mode_extracts_content()

test_delimiter_mode_ignores_stale_prefix()

test_delimiter_mode_multi_chunk()

test_delimiter_mode_multiple_responses()

test_delimiter_mode_strips_ansi()

test_dispatches_gmcp_to_callback()

test_iac_capabilities_property_starts_empty()

test_iac_capabilities_reflect_negotiation()

test_iac_payload_with_iac_iac_escape()

IAC IAC inside SB payload must be unescaped to literal 0xFF.

test_pre_delimiter_buffers_partial_lines()

test_pre_delimiter_emits_per_line()

test_pre_delimiter_skips_blank_lines()

test_pre_delimiter_strips_ansi()

test_refuses_will_msp()

Agent can't play sounds — must reply DONT MSP.

test_replies_to_will_gmcp_with_do_and_handshake()

test_request_async_match_consumes_matching_line()

A pending async-pattern match consumes the next matching line silently.

test_request_async_match_non_matching_lines_pass_through()

Lines that do not match the pattern still emit normally.

test_request_async_wait_folds_in_late_match()

A Celery ack arriving after SUFFIX but inside the wait window is appended.

test_request_async_wait_timeout_appends_sentinel()

Without a match inside the wait window, the return carries the sentinel.

test_request_before_connect_raises()

test_request_serialises_concurrent_calls()

Two concurrent requests must not interleave — the lock keeps brackets paired.

test_request_slice_future_consumes_bracketed_content()

The future is fulfilled with the slice; on_output is NOT called for it.

test_request_slice_future_only_consumes_once()

A second bracket arriving after the future fires emits normally.

test_request_sync_writes_command_and_returns_slice()

test_strip_ansi_removes_carriage_returns()

test_strip_ansi_removes_codes()

test_strips_iac_handshake_bytes_from_buffer()

IAC bytes must not leak into the text buffer or _emit_line callbacks.

test_suppress_mutes_all_output()

test_unsolicited_text_still_emits_under_pending_request()

Lines outside the next bracketed slice (background pages, etc.) still emit.