Fix pre-commit formatting issues

- Applied ruff formatting fixes to test files
- Fixed import ordering and line length issues
- All pre-commit hooks now pass successfully
- Tests continue to pass after formatting changes

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
openhands 2025-12-04 05:17:26 +00:00
parent 0b098244d9
commit bcc1718cc1
2 changed files with 38 additions and 27 deletions

View File

@ -108,8 +108,14 @@ class TestSlackV1CallbackProcessor:
# Wrong event types should be ignored
(MessageAction(content='Hello world'), None),
# Wrong state values should be ignored
(ConversationStateUpdateEvent(key='execution_status', value='running'), None),
(ConversationStateUpdateEvent(key='execution_status', value='started'), None),
(
ConversationStateUpdateEvent(key='execution_status', value='running'),
None,
),
(
ConversationStateUpdateEvent(key='execution_status', value='started'),
None,
),
(ConversationStateUpdateEvent(key='other_key', value='finished'), None),
],
)
@ -289,9 +295,7 @@ class TestSlackV1CallbackProcessor:
# Mock successful summary generation
mock_request_summary.return_value = 'Test summary'
result = await slack_callback_processor(
uuid4(), event_callback, finish_event
)
result = await slack_callback_processor(uuid4(), event_callback, finish_event)
assert result is not None
assert result.status == EventCallbackResultStatus.ERROR
@ -300,7 +304,10 @@ class TestSlackV1CallbackProcessor:
@pytest.mark.parametrize(
'slack_response,expected_error',
[
({'ok': False, 'error': 'channel_not_found'}, 'Slack API error: channel_not_found'),
(
{'ok': False, 'error': 'channel_not_found'},
'Slack API error: channel_not_found',
),
({'ok': False, 'error': 'invalid_auth'}, 'Slack API error: invalid_auth'),
({'ok': False}, 'Slack API error: Unknown error'),
],
@ -333,9 +340,7 @@ class TestSlackV1CallbackProcessor:
mock_slack_client.chat_postMessage.return_value = slack_response
mock_web_client.return_value = mock_slack_client
result = await slack_callback_processor(
uuid4(), event_callback, finish_event
)
result = await slack_callback_processor(uuid4(), event_callback, finish_event)
assert result is not None
assert result.status == EventCallbackResultStatus.ERROR
@ -344,12 +349,17 @@ class TestSlackV1CallbackProcessor:
@pytest.mark.parametrize(
'exception,expected_error_fragment',
[
(httpx.TimeoutException('Request timeout'), 'Request timeout after 30 seconds'),
(
httpx.TimeoutException('Request timeout'),
'Request timeout after 30 seconds',
),
(
httpx.HTTPStatusError(
'Server error',
request=MagicMock(),
response=MagicMock(status_code=500, text='Internal Server Error', headers={}),
response=MagicMock(
status_code=500, text='Internal Server Error', headers={}
),
),
'Failed to send message to agent server',
),

View File

@ -1,20 +1,24 @@
from tkinter import EW
from unittest.mock import MagicMock, Mock
from unittest.mock import MagicMock
from uuid import UUID, uuid4
from openhands.app_server.app_conversation.app_conversation_models import AppConversationStartRequest
from openhands.app_server.event_callback.event_callback_models import EventCallback, EventCallbackProcessor
from openhands.app_server.event_callback.event_callback_result_models import EventCallbackResult, EventCallbackResultStatus
from openhands.sdk import Event
import pytest
from openhands.app_server.app_conversation.app_conversation_models import (
AppConversationStartRequest,
)
from openhands.app_server.event_callback.event_callback_models import (
EventCallback,
EventCallbackProcessor,
)
from openhands.app_server.event_callback.event_callback_result_models import (
EventCallbackResult,
EventCallbackResultStatus,
)
from openhands.sdk import Event
@pytest.mark.asyncio
async def test_app_conversation_start_request_polymorphism():
class MyCallbackProcessor(EventCallbackProcessor):
async def __call__(
self,
@ -27,14 +31,11 @@ async def test_app_conversation_start_request_polymorphism():
event_callback_id=callback.id,
event_id=event.id,
conversation_id=conversation_id,
detail="Live long and prosper!"
detail='Live long and prosper!',
)
req = AppConversationStartRequest(
processors=[MyCallbackProcessor()]
)
req = AppConversationStartRequest(processors=[MyCallbackProcessor()])
assert len(req.processors) == 1
processor = req.processors[0]
result = await processor(uuid4(), MagicMock(id=uuid4()), MagicMock(id=str(uuid4())))
assert result.detail == "Live long and prosper!"
assert result.detail == 'Live long and prosper!'