mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
|
|
# Fixture: mock_verified_models - Simplified model data
|
|
@pytest.fixture
|
|
def mock_verified_models():
|
|
with (
|
|
patch(
|
|
'openhands_cli.user_actions.settings_action.VERIFIED_MODELS',
|
|
{
|
|
'openai': ['gpt-4o', 'gpt-4o-mini'],
|
|
'anthropic': ['claude-3-5-sonnet', 'claude-3-5-haiku'],
|
|
},
|
|
),
|
|
patch(
|
|
'openhands_cli.user_actions.settings_action.UNVERIFIED_MODELS_EXCLUDING_BEDROCK',
|
|
{
|
|
'openai': ['gpt-custom'],
|
|
'anthropic': [],
|
|
'custom': ['my-model'],
|
|
},
|
|
),
|
|
):
|
|
yield
|
|
|
|
|
|
# Fixture: mock_cli_interactions - Reusable CLI mock patterns
|
|
@pytest.fixture
|
|
def mock_cli_interactions():
|
|
class Mocks:
|
|
def __init__(self):
|
|
self.p_confirm = patch(
|
|
'openhands_cli.user_actions.settings_action.cli_confirm'
|
|
)
|
|
self.p_text = patch(
|
|
'openhands_cli.user_actions.settings_action.cli_text_input'
|
|
)
|
|
self.cli_confirm = None
|
|
self.cli_text_input = None
|
|
|
|
def start(self):
|
|
self.cli_confirm = self.p_confirm.start()
|
|
self.cli_text_input = self.p_text.start()
|
|
return self
|
|
|
|
def stop(self):
|
|
self.p_confirm.stop()
|
|
self.p_text.stop()
|
|
|
|
mocks = Mocks().start()
|
|
try:
|
|
yield mocks
|
|
finally:
|
|
mocks.stop()
|