mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-25 21:36:52 +08:00
Fix GCP async connection test mock setup
The test_gcp_async_connection_creation test was incorrectly mocking the Connector class for async context manager usage, but the actual implementation creates the connector directly and calls connect_async. Changed mock setup to: - Use MagicMock for the connector (not AsyncMock) - Set Connector.return_value directly (not through __aenter__) - Use AsyncMock for connect_async method Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
864f775697
commit
8102b51750
@ -456,13 +456,10 @@ class TestDbSessionInjectorGCPIntegration:
|
||||
# Mock the google.cloud.sql.connector module
|
||||
with patch.dict('sys.modules', {'google.cloud.sql.connector': MagicMock()}):
|
||||
mock_connector_module = sys.modules['google.cloud.sql.connector']
|
||||
mock_connector = AsyncMock()
|
||||
mock_connector_module.Connector.return_value.__aenter__.return_value = (
|
||||
mock_connector
|
||||
)
|
||||
mock_connector_module.Connector.return_value.__aexit__.return_value = None
|
||||
mock_connector = MagicMock()
|
||||
mock_connector_module.Connector.return_value = mock_connector
|
||||
mock_connection = AsyncMock()
|
||||
mock_connector.connect_async.return_value = mock_connection
|
||||
mock_connector.connect_async = AsyncMock(return_value=mock_connection)
|
||||
|
||||
connection = await gcp_db_session_injector._create_async_gcp_db_connection()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user