File size: 1,460 Bytes
246d201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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'
|