feat: 重构 memory 系统,支持 user memory 和 work memory 分离
This commit is contained in:
@@ -12,6 +12,14 @@ from v1.auth.schemas import (
|
||||
from v1.auth.service import AuthService, AuthServiceGateway
|
||||
|
||||
|
||||
class FakeRegistrationBootstrapper:
|
||||
def __init__(self) -> None:
|
||||
self.called_user_ids: list[str] = []
|
||||
|
||||
async def ensure_user_automation_jobs(self, *, user_id: str) -> None:
|
||||
self.called_user_ids.append(user_id)
|
||||
|
||||
|
||||
class FakeGateway(AuthServiceGateway):
|
||||
def __init__(self, response: SessionResponse) -> None:
|
||||
self._response = response
|
||||
@@ -75,6 +83,27 @@ async def test_create_phone_session_forwards_payload() -> None:
|
||||
assert response.user.phone == "+8613812345678"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_phone_session_bootstraps_automation_job() -> None:
|
||||
user = AuthUser(id="b196f8be-c5f4-45d8-8f07-65c0ddf4d3de", phone="+8613812345678")
|
||||
token_response = SessionResponse(
|
||||
access_token="access",
|
||||
refresh_token="refresh",
|
||||
expires_in=3600,
|
||||
token_type="bearer",
|
||||
user=user,
|
||||
)
|
||||
gateway = FakeGateway(token_response)
|
||||
bootstrapper = FakeRegistrationBootstrapper()
|
||||
service = AuthService(gateway=gateway, registration_bootstrapper=bootstrapper)
|
||||
|
||||
await service.create_phone_session(
|
||||
PhoneSessionCreateRequest(phone="+8613812345678", token="123456")
|
||||
)
|
||||
|
||||
assert bootstrapper.called_user_ids == ["b196f8be-c5f4-45d8-8f07-65c0ddf4d3de"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_refresh_session_forwards_payload() -> None:
|
||||
user = AuthUser(id="user-1", phone="+8613812345678")
|
||||
|
||||
Reference in New Issue
Block a user