32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
|
|
from app.gateway.routers import threads
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_delete_thread_does_not_delete_thread_memory():
|
|
request = SimpleNamespace(app=SimpleNamespace(state=SimpleNamespace(checkpointer=None, store=None)))
|
|
with (
|
|
patch("app.gateway.routers.threads._delete_thread_data", return_value=threads.ThreadDeleteResponse(success=True, message="ok")),
|
|
patch("app.gateway.routers.threads.get_store", return_value=None),
|
|
patch("app.gateway.routers.threads.delete_thread_memory_data") as delete_memory,
|
|
):
|
|
response = await threads.delete_thread_data("thread-1", request)
|
|
|
|
assert response.success is True
|
|
delete_memory.assert_not_called()
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_delete_thread_memory_endpoint_calls_cleanup():
|
|
with patch("app.gateway.routers.threads.delete_thread_memory_data") as delete_memory:
|
|
response = await threads.delete_thread_memory("thread-1")
|
|
|
|
assert response.success is True
|
|
assert response.message == "Deleted thread memory for thread-1"
|
|
delete_memory.assert_called_once_with("thread-1")
|
|
|