2026-02-20 23:41:44 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-03-17 10:16:44 +08:00
|
|
|
from yuxi.repositories.conversation_repository import ConversationRepository, MAX_CONVERSATION_TITLE_LENGTH
|
2026-02-20 23:41:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_normalize_title_truncates_when_too_long():
|
|
|
|
|
repo = ConversationRepository(None) # type: ignore[arg-type]
|
|
|
|
|
raw = "a" * (MAX_CONVERSATION_TITLE_LENGTH + 50)
|
|
|
|
|
|
|
|
|
|
normalized = repo._normalize_title(raw)
|
|
|
|
|
|
|
|
|
|
assert normalized is not None
|
|
|
|
|
assert len(normalized) == MAX_CONVERSATION_TITLE_LENGTH
|
|
|
|
|
assert normalized == "a" * MAX_CONVERSATION_TITLE_LENGTH
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_normalize_title_trims_spaces():
|
|
|
|
|
repo = ConversationRepository(None) # type: ignore[arg-type]
|
|
|
|
|
|
|
|
|
|
normalized = repo._normalize_title(" hello world ")
|
|
|
|
|
|
|
|
|
|
assert normalized == "hello world"
|