fix: improve maintenance and synchronize live conversations

This commit is contained in:
WangShen007 committed 2026-10-29 09:46:21 +08:00
1 parent bb541bd212
commit ef86a5d3af
297 files changed
+2983 -1274

No files matched your search

+2 -9
View File
@@ -16,7 +16,6 @@ limitations under the License.
import asyncio
import pytest
from fastapi.testclient import TestClient
from app.core.config import settings
from app.models.user import User
from app.models.role import Role
@@ -27,9 +26,7 @@ from app.models.customer import Customer
from app.models.agent import Agent, AgentType
from app.models.schemas.jira import AgentWithJiraConfig
from app.agents.chat_agent import ChatAgent, ChatResponse, TransferReasonType
from app.repositories.ai_config import AIConfigRepository
from uuid import uuid4
from datetime import datetime, timezone
from unittest.mock import patch, MagicMock
from agno.storage.base import Storage
from fastapi import HTTPException
@@ -182,11 +179,7 @@ def test_session(db, test_organization_id, test_customer, test_agent) -> Session
@pytest.fixture
def mock_db_session(db):
"""Mock database session for ChatAgent"""
def get_mock_db():
yield db
with patch('app.agents.chat_agent.get_db', get_mock_db), \
patch('app.tools.knowledge_search_byagent.SessionLocal') as mock_knowledge_session_local, \
with patch('app.tools.knowledge_search_byagent.SessionLocal') as mock_knowledge_session_local, \
patch('app.agents.chat_agent.SessionLocal') as mock_chat_agent_session_local:
# Setup SessionLocal to return our test db when used as context manager
mock_knowledge_session_local.return_value.__enter__.return_value = db
@@ -452,4 +445,4 @@ async def test_chat_agent_run_timeout(test_organization_id, test_agent, test_use
assert isinstance(response, ChatResponse)
assert "error" in response.message.lower()
assert not response.transfer_to_human
assert not response.transfer_to_human