moo.agent.tests.test_lore

Tests for moo/agent/lore.py.

The curation is pure functions exercised directly; LoreClient is driven by a fake MCP server so the assembly, canonical preference, and graceful-failure paths are covered without a live krustylu endpoint. No DJANGO_SETTINGS_MODULE.

Functions

test_build_character_brief_header_and_gender()

build_character_brief prefers display_name and shows gender plus the slug token.

test_build_room_brief_omits_empty_sections()

Sections with no data are omitted rather than rendered empty.

test_build_room_brief_sections_and_line_cap()

build_room_brief renders all sections and truncates an over-long dialogue line.

test_condense_description_cuts_at_heading_and_strips_links()

condense_description keeps the intro, drops links, and stops at the first heading.

test_condense_description_empty()

An empty description condenses to an empty string.

test_condense_description_truncates_on_sentence_boundary()

A long description is clipped near max_chars, preferring a sentence end.

test_queries_degrade_when_server_unset()

With no open session, lookups return empty without raising.

test_query_swallows_server_errors()

A raising MCP call is caught and reported as an empty result.

test_resolve_prefers_canonical()

_resolve picks the canonical row even when a variant ranks first.

test_room_brief_full_assembly()

LoreClient.room_brief resolves a location and folds the queries into a brief.

test_room_brief_miss_returns_empty()

A location that resolves to nothing yields an empty string, not an error.

test_sanitize_query_removes_quotes()

sanitize_query strips the quote chars that break krustylu's FTS parser.

test_strip_md_links_plain_and_titled()

strip_md_links reduces [label](url) and [label](url "title") to the label.

test_top_speaker_ids_sorts_and_drops_null()

top_speaker_ids ranks by count, drops null character ids, and honors the limit.