refactor(backend): update API routes and service layer
- Update agent router/service/repository with new endpoints - Update auth routes with phone-based authentication - Update users service with new phone lookup - Update schedule_items with new schemas - Update message schemas with visibility support - Update settings with new automation scheduler config - Update CLI with new commands - Update tests to match new API contracts
This commit is contained in:
@@ -7,6 +7,8 @@ from uuid import uuid4
|
||||
import pytest
|
||||
|
||||
from models.agent_chat_message import AgentChatMessageRole
|
||||
from sqlalchemy import select
|
||||
from models.agent_chat_message import AgentChatMessage
|
||||
from v1.agent.repository import AgentRepository
|
||||
|
||||
|
||||
@@ -79,6 +81,7 @@ async def test_persist_user_message_sets_session_title_when_empty() -> None:
|
||||
session_id=session_id,
|
||||
content=" 请帮我安排明天下午开会 ",
|
||||
metadata=None,
|
||||
visibility_mask=1,
|
||||
)
|
||||
|
||||
assert session_row.title == "请帮我安排明天下午开会"
|
||||
@@ -101,6 +104,7 @@ async def test_persist_user_message_keeps_existing_session_title() -> None:
|
||||
session_id=session_id,
|
||||
content="新的消息内容",
|
||||
metadata=None,
|
||||
visibility_mask=1,
|
||||
)
|
||||
|
||||
assert session_row.title == "已有标题"
|
||||
@@ -164,3 +168,13 @@ async def test_get_history_day_uses_target_day_queries_only() -> None:
|
||||
messages = payload["messages"]
|
||||
assert isinstance(messages, list)
|
||||
assert len(messages) == 1
|
||||
|
||||
|
||||
def test_apply_visibility_filter_adds_bitwise_expression() -> None:
|
||||
repository = AgentRepository(session=SimpleNamespace()) # type: ignore[arg-type]
|
||||
stmt = select(AgentChatMessage)
|
||||
|
||||
filtered = repository._apply_visibility_filter(stmt=stmt, visibility_mask=1)
|
||||
|
||||
assert "visibility_mask" in str(filtered)
|
||||
assert "&" in str(filtered)
|
||||
|
||||
Reference in New Issue
Block a user