Fix for delete conversation (#6097)

This commit is contained in:
tofarr 2025-01-07 08:25:45 -07:00 committed by GitHub
parent aad7a612c1
commit eaf4c610b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from pydantic import TypeAdapter
@ -39,7 +40,9 @@ class FileConversationStore(ConversationStore):
return result
async def delete_metadata(self, conversation_id: str) -> None:
path = self.get_conversation_metadata_filename(conversation_id)
path = str(
Path(self.get_conversation_metadata_filename(conversation_id)).parent
)
await call_sync_from_async(self.file_store.delete, path)
async def exists(self, conversation_id: str) -> bool:

View File

@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch
import pytest
from openhands.server.routes.manage_conversations import (
delete_conversation,
get_conversation,
search_conversations,
update_conversation,
@ -114,3 +115,16 @@ async def test_update_conversation():
selected_repository='foobar',
)
assert conversation == expected
@pytest.mark.asyncio
async def test_delete_conversation():
with _patch_store():
await delete_conversation(
'some_conversation_id',
MagicMock(state=MagicMock(github_token='')),
)
conversation = await get_conversation(
'some_conversation_id', MagicMock(state=MagicMock(github_token=''))
)
assert conversation is None