Skip to content

Fix for issue where running unit tests resets local settings #8100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions tests/unit/test_settings_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from openhands.integrations.provider import ProviderToken, ProviderType
from openhands.server.app import app
from openhands.server.user_auth.user_auth import UserAuth
from openhands.storage.memory import InMemoryFileStore
from openhands.storage.settings.file_settings_store import FileSettingsStore
from openhands.storage.settings.settings_store import SettingsStore


Expand Down Expand Up @@ -40,16 +42,22 @@ async def get_instance(cls, request: Request) -> UserAuth:
@pytest.fixture
def test_client():
# Create a test client
with patch(
'openhands.server.user_auth.user_auth.UserAuth.get_instance',
return_value=MockUserAuth(),
):
with patch(
with (
patch(
'openhands.server.user_auth.user_auth.UserAuth.get_instance',
return_value=MockUserAuth(),
),
patch(
'openhands.server.routes.settings.validate_provider_token',
return_value=ProviderType.GITHUB,
):
client = TestClient(app)
yield client
),
patch(
'openhands.storage.settings.file_settings_store.FileSettingsStore.get_instance',
AsyncMock(return_value=FileSettingsStore(InMemoryFileStore()))
)
):
client = TestClient(app)
yield client


@pytest.mark.asyncio
Expand Down
Loading