chore: update gitignore; feat: 新增customer_agent业务模块与api路由
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import unittest
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from service.customer_agent.config import DatabaseConfigProvider
|
||||
|
||||
|
||||
class ConfigProviderTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_reads_sys_config_value_and_uses_default_when_missing(self):
|
||||
repo = AsyncMock()
|
||||
repo.get_value.side_effect = ["120", "fallback"]
|
||||
|
||||
class SessionContext:
|
||||
async def __aenter__(self):
|
||||
return object()
|
||||
|
||||
async def __aexit__(self, *args):
|
||||
pass
|
||||
|
||||
provider = DatabaseConfigProvider(
|
||||
repo_factory=lambda session: repo,
|
||||
session_factory=lambda: SessionContext(),
|
||||
)
|
||||
|
||||
self.assertEqual(await provider.get("agent.customer.session.ttl", "60"), "120")
|
||||
self.assertEqual(await provider.get("missing", "fallback"), "fallback")
|
||||
self.assertEqual(repo.get_value.await_count, 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user