forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_file_conversation_store.py
42 lines (36 loc) · 1.38 KB
/
test_file_conversation_store.py
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
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'