|
import json
|
|
|
|
import pytest
|
|
|
|
from openhands.storage.conversation.file_conversation_store import FileConversationStore
|
|
from openhands.storage.data_models.conversation_metadata import ConversationMetadata
|
|
from openhands.storage.memory import InMemoryFileStore
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_load_store():
|
|
store = FileConversationStore(InMemoryFileStore({}))
|
|
expected = ConversationMetadata(
|
|
conversation_id='some-conversation-id',
|
|
github_user_id='some-user-id',
|
|
selected_repository='some-repo',
|
|
title="Let's talk about trains",
|
|
)
|
|
await store.save_metadata(expected)
|
|
found = await store.get_metadata('some-conversation-id')
|
|
assert expected == found
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_load_int_user_id():
|
|
store = FileConversationStore(
|
|
InMemoryFileStore(
|
|
{
|
|
'sessions/some-conversation-id/metadata.json': json.dumps(
|
|
{
|
|
'conversation_id': 'some-conversation-id',
|
|
'github_user_id': 12345,
|
|
'selected_repository': 'some-repo',
|
|
'title': "Let's talk about trains",
|
|
'created_at': '2025-01-16T19:51:04.886331Z',
|
|
}
|
|
)
|
|
}
|
|
)
|
|
)
|
|
found = await store.get_metadata('some-conversation-id')
|
|
assert found.github_user_id == '12345'
|
|
|