This commit is contained in:
Tim O'Farrell 2025-12-22 20:28:04 -07:00
parent f19fb10435
commit dc600a4d91
3 changed files with 66 additions and 66 deletions

View File

@ -5860,7 +5860,7 @@ wsproto = ">=1.2.0"
[[package]]
name = "openhands-ai"
version = "0.0.0-post.5715+59daf1635"
version = "0.0.0-post.5750+f19fb1043"
description = "OpenHands: Code Less, Make More"
optional = false
python-versions = "^3.12,<3.14"

View File

@ -59,7 +59,7 @@ async def async_session(async_engine) -> AsyncGenerator[AsyncSession, None]:
@pytest.fixture
async def public_conversation_service(async_session):
async def shared_conversation_info_service(async_session):
"""Create a SharedConversationInfoService for testing."""
return SQLSharedConversationInfoService(db_session=async_session)
@ -145,20 +145,20 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
@pytest.mark.asyncio
async def test_get_public_conversation_info_returns_public_conversation(
async def test_get_shared_conversation_info_returns_public_conversation(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_conversation_info,
):
"""Test that get_public_conversation_info returns a public conversation."""
"""Test that get_shared_conversation_info returns a public conversation."""
# Create a public conversation
await app_conversation_service.save_app_conversation_info(
sample_conversation_info
)
# Retrieve it via public service
result = await public_conversation_service.get_public_conversation_info(
result = await shared_conversation_info_service.get_shared_conversation_info(
sample_conversation_info.id
)
@ -168,32 +168,32 @@ class TestSharedConversationInfoService:
assert result.created_by_user_id == sample_conversation_info.created_by_user_id
@pytest.mark.asyncio
async def test_get_public_conversation_info_returns_none_for_private_conversation(
async def test_get_shared_conversation_info_returns_none_for_private_conversation(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_private_conversation_info,
):
"""Test that get_public_conversation_info returns None for private conversations."""
"""Test that get_shared_conversation_info returns None for private conversations."""
# Create a private conversation
await app_conversation_service.save_app_conversation_info(
sample_private_conversation_info
)
# Try to retrieve it via public service
result = await public_conversation_service.get_public_conversation_info(
result = await shared_conversation_info_service.get_shared_conversation_info(
sample_private_conversation_info.id
)
assert result is None
@pytest.mark.asyncio
async def test_get_public_conversation_info_returns_none_for_nonexistent_conversation(
self, public_conversation_service
async def test_get_shared_conversation_info_returns_none_for_nonexistent_conversation(
self, shared_conversation_info_service
):
"""Test that get_public_conversation_info returns None for nonexistent conversations."""
"""Test that get_shared_conversation_info returns None for nonexistent conversations."""
nonexistent_id = uuid4()
result = await public_conversation_service.get_public_conversation_info(
result = await shared_conversation_info_service.get_shared_conversation_info(
nonexistent_id
)
assert result is None
@ -201,7 +201,7 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
async def test_search_public_conversation_info_returns_only_public_conversations(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_conversation_info,
sample_private_conversation_info,
@ -216,7 +216,7 @@ class TestSharedConversationInfoService:
)
# Search for all conversations
result = await public_conversation_service.search_public_conversation_info()
result = await shared_conversation_info_service.search_public_conversation_info()
# Should only return the public conversation
assert len(result.items) == 1
@ -226,7 +226,7 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
async def test_search_public_conversation_info_with_title_filter(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_conversation_info,
):
@ -237,13 +237,13 @@ class TestSharedConversationInfoService:
)
# Search with matching title
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
title__contains='Test'
)
assert len(result.items) == 1
# Search with non-matching title
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
title__contains='NonExistent'
)
assert len(result.items) == 0
@ -251,7 +251,7 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
async def test_search_public_conversation_info_with_sort_order(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
):
"""Test searching with different sort orders."""
@ -289,7 +289,7 @@ class TestSharedConversationInfoService:
await app_conversation_service.save_app_conversation_info(conv2)
# Test sort by title ascending
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
sort_order=SharedConversationSortOrder.TITLE
)
assert len(result.items) == 2
@ -297,7 +297,7 @@ class TestSharedConversationInfoService:
assert result.items[1].title == 'B Second Conversation'
# Test sort by title descending
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
sort_order=SharedConversationSortOrder.TITLE_DESC
)
assert len(result.items) == 2
@ -305,7 +305,7 @@ class TestSharedConversationInfoService:
assert result.items[1].title == 'A First Conversation'
# Test sort by created_at ascending
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
sort_order=SharedConversationSortOrder.CREATED_AT
)
assert len(result.items) == 2
@ -313,7 +313,7 @@ class TestSharedConversationInfoService:
assert result.items[1].id == conv2.id
# Test sort by created_at descending (default)
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
sort_order=SharedConversationSortOrder.CREATED_AT_DESC
)
assert len(result.items) == 2
@ -323,34 +323,34 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
async def test_count_public_conversation_info(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_conversation_info,
sample_private_conversation_info,
):
"""Test counting public conversations."""
# Initially should be 0
count = await public_conversation_service.count_public_conversation_info()
count = await shared_conversation_info_service.count_public_conversation_info()
assert count == 0
# Create a public conversation
await app_conversation_service.save_app_conversation_info(
sample_conversation_info
)
count = await public_conversation_service.count_public_conversation_info()
count = await shared_conversation_info_service.count_public_conversation_info()
assert count == 1
# Create a private conversation - count should remain 1
await app_conversation_service.save_app_conversation_info(
sample_private_conversation_info
)
count = await public_conversation_service.count_public_conversation_info()
count = await shared_conversation_info_service.count_public_conversation_info()
assert count == 1
@pytest.mark.asyncio
async def test_batch_get_public_conversation_info(
async def test_batch_get_shared_conversation_info(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
sample_conversation_info,
sample_private_conversation_info,
@ -365,7 +365,7 @@ class TestSharedConversationInfoService:
)
# Batch get both conversations
result = await public_conversation_service.batch_get_public_conversation_info(
result = await shared_conversation_info_service.batch_get_shared_conversation_info(
[sample_conversation_info.id, sample_private_conversation_info.id]
)
@ -378,7 +378,7 @@ class TestSharedConversationInfoService:
@pytest.mark.asyncio
async def test_search_with_pagination(
self,
public_conversation_service,
shared_conversation_info_service,
app_conversation_service,
):
"""Test search with pagination."""
@ -403,14 +403,14 @@ class TestSharedConversationInfoService:
await app_conversation_service.save_app_conversation_info(conv)
# Get first page with limit 2
result = await public_conversation_service.search_public_conversation_info(
result = await shared_conversation_info_service.search_public_conversation_info(
limit=2, sort_order=SharedConversationSortOrder.CREATED_AT
)
assert len(result.items) == 2
assert result.next_page_id is not None
# Get next page
result2 = await public_conversation_service.search_public_conversation_info(
result2 = await shared_conversation_info_service.search_public_conversation_info(
limit=2,
page_id=result.next_page_id,
sort_order=SharedConversationSortOrder.CREATED_AT,

View File

@ -20,7 +20,7 @@ from openhands.sdk.llm.utils.metrics import TokenUsage
@pytest.fixture
def mock_public_conversation_service():
def mock_shared_conversation_info_service():
"""Create a mock SharedConversationInfoService."""
return AsyncMock(spec=SharedConversationInfoService)
@ -32,10 +32,10 @@ def mock_event_service():
@pytest.fixture
def shared_event_service(mock_public_conversation_service, mock_event_service):
def shared_event_service(mock_shared_conversation_info_service, mock_event_service):
"""Create a SharedEventService for testing."""
return SharedEventServiceImpl(
public_conversation_service=mock_public_conversation_service,
shared_conversation_info_service=mock_shared_conversation_info_service,
event_service=mock_event_service,
)
@ -69,10 +69,10 @@ def sample_event():
class TestSharedEventService:
"""Test cases for SharedEventService."""
async def test_get_public_event_returns_event_for_public_conversation(
async def test_get_shared_event_returns_event_for_public_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
sample_public_conversation,
sample_event,
@ -82,7 +82,7 @@ class TestSharedEventService:
event_id = 'test_event_id'
# Mock the public conversation service to return a public conversation
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
sample_public_conversation
)
@ -94,7 +94,7 @@ class TestSharedEventService:
# Verify the result
assert result == sample_event
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
mock_event_service.get_event.assert_called_once_with(event_id)
@ -102,7 +102,7 @@ class TestSharedEventService:
async def test_get_public_event_returns_none_for_private_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
):
"""Test that get_public_event returns None for a private conversation."""
@ -110,7 +110,7 @@ class TestSharedEventService:
event_id = 'test_event_id'
# Mock the public conversation service to return None (private conversation)
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
None
)
@ -119,7 +119,7 @@ class TestSharedEventService:
# Verify the result
assert result is None
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
# Event service should not be called
@ -128,7 +128,7 @@ class TestSharedEventService:
async def test_search_public_events_returns_events_for_public_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
sample_public_conversation,
sample_event,
@ -137,7 +137,7 @@ class TestSharedEventService:
conversation_id = sample_public_conversation.id
# Mock the public conversation service to return a public conversation
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
sample_public_conversation
)
@ -156,7 +156,7 @@ class TestSharedEventService:
assert result == mock_event_page
assert len(result.items) == 0 # Empty list as we mocked
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
mock_event_service.search_events.assert_called_once_with(
@ -172,14 +172,14 @@ class TestSharedEventService:
async def test_search_public_events_returns_empty_for_private_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
):
"""Test that search_public_events returns empty page for a private conversation."""
conversation_id = uuid4()
# Mock the public conversation service to return None (private conversation)
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
None
)
@ -194,7 +194,7 @@ class TestSharedEventService:
assert len(result.items) == 0
assert result.next_page_id is None
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
# Event service should not be called
@ -203,7 +203,7 @@ class TestSharedEventService:
async def test_count_public_events_returns_count_for_public_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
sample_public_conversation,
):
@ -211,7 +211,7 @@ class TestSharedEventService:
conversation_id = sample_public_conversation.id
# Mock the public conversation service to return a public conversation
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
sample_public_conversation
)
@ -227,7 +227,7 @@ class TestSharedEventService:
# Verify the result
assert result == 5
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
mock_event_service.count_events.assert_called_once_with(
@ -241,14 +241,14 @@ class TestSharedEventService:
async def test_count_public_events_returns_zero_for_private_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
):
"""Test that count_public_events returns 0 for a private conversation."""
conversation_id = uuid4()
# Mock the public conversation service to return None (private conversation)
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
None
)
@ -260,7 +260,7 @@ class TestSharedEventService:
# Verify the result
assert result == 0
mock_public_conversation_service.get_public_conversation_info.assert_called_once_with(
mock_shared_conversation_info_service.get_shared_conversation_info.assert_called_once_with(
conversation_id
)
# Event service should not be called
@ -269,7 +269,7 @@ class TestSharedEventService:
async def test_batch_get_public_events_returns_events_for_public_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
sample_public_conversation,
sample_event,
@ -279,7 +279,7 @@ class TestSharedEventService:
event_ids = ['event1', 'event2']
# Mock the public conversation service to return a public conversation
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
sample_public_conversation
)
@ -296,9 +296,9 @@ class TestSharedEventService:
assert result[0] == sample_event
assert result[1] is None
# Verify that get_public_conversation_info was called for each event
# Verify that get_shared_conversation_info was called for each event
assert (
mock_public_conversation_service.get_public_conversation_info.call_count
mock_shared_conversation_info_service.get_shared_conversation_info.call_count
== 2
)
# Verify that get_event was called for each event
@ -307,7 +307,7 @@ class TestSharedEventService:
async def test_batch_get_public_events_returns_none_for_private_conversation(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
):
"""Test that batch_get_public_events returns None for a private conversation."""
@ -315,7 +315,7 @@ class TestSharedEventService:
event_ids = ['event1', 'event2']
# Mock the public conversation service to return None (private conversation)
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
None
)
@ -329,9 +329,9 @@ class TestSharedEventService:
assert result[0] is None
assert result[1] is None
# Verify that get_public_conversation_info was called for each event
# Verify that get_shared_conversation_info was called for each event
assert (
mock_public_conversation_service.get_public_conversation_info.call_count
mock_shared_conversation_info_service.get_shared_conversation_info.call_count
== 2
)
# Event service should not be called
@ -340,7 +340,7 @@ class TestSharedEventService:
async def test_search_public_events_with_all_parameters(
self,
shared_event_service,
mock_public_conversation_service,
mock_shared_conversation_info_service,
mock_event_service,
sample_public_conversation,
):
@ -350,7 +350,7 @@ class TestSharedEventService:
timestamp_lt = datetime(2023, 12, 31, tzinfo=UTC)
# Mock the public conversation service to return a public conversation
mock_public_conversation_service.get_public_conversation_info.return_value = (
mock_shared_conversation_info_service.get_shared_conversation_info.return_value = (
sample_public_conversation
)