π OpenHands: AI-Driven Development
Fix for issue where running unit tests resets local settings (#8100)
tofarr998e04e51be4
diff --git a/tests/unit/test_settings_api.py b/tests/unit/test_settings_api.pyindex b184cebd5a..25e5b81676 100644--- a/tests/unit/test_settings_api.py+++ b/tests/unit/test_settings_api.py@@ -8,6 +8,8 @@ from pydantic import SecretStrfrom openhands.integrations.provider import ProviderToken, ProviderTypefrom openhands.server.app import appfrom openhands.server.user_auth.user_auth import UserAuth+from openhands.storage.memory import InMemoryFileStore+from openhands.storage.settings.file_settings_store import FileSettingsStorefrom openhands.storage.settings.settings_store import SettingsStore@@ -40,16 +42,22 @@ class MockUserAuth(UserAuth):@pytest.fixturedef 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