39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from decimal import Decimal
|
|
from uuid import UUID
|
|
|
|
from models.agent_chat_session import AgentChatSession, AgentChatSessionStatus
|
|
from v1.agent.service import select_recent_session
|
|
|
|
|
|
def test_recent_session_home_default_selection() -> None:
|
|
sessions = [
|
|
AgentChatSession(
|
|
id=UUID("00000000-0000-0000-0000-0000000000a1"),
|
|
user_id=UUID("00000000-0000-0000-0000-0000000000c1"),
|
|
title="older",
|
|
status=AgentChatSessionStatus.COMPLETED,
|
|
last_activity_at=datetime(2026, 2, 25, 8, 0, tzinfo=timezone.utc),
|
|
message_count=2,
|
|
total_tokens=100,
|
|
total_cost=Decimal("0.010000"),
|
|
),
|
|
AgentChatSession(
|
|
id=UUID("00000000-0000-0000-0000-0000000000a2"),
|
|
user_id=UUID("00000000-0000-0000-0000-0000000000c1"),
|
|
title="newer",
|
|
status=AgentChatSessionStatus.RUNNING,
|
|
last_activity_at=datetime(2026, 2, 25, 9, 0, tzinfo=timezone.utc),
|
|
message_count=3,
|
|
total_tokens=120,
|
|
total_cost=Decimal("0.020000"),
|
|
),
|
|
]
|
|
|
|
selected = select_recent_session(sessions)
|
|
|
|
assert selected is not None
|
|
assert selected.id == UUID("00000000-0000-0000-0000-0000000000a2")
|