dabla commented on code in PR #61546:
URL: https://github.com/apache/airflow/pull/61546#discussion_r2784149216
##########
providers/google/tests/unit/google/cloud/hooks/test_cloud_run.py:
##########
@@ -293,6 +308,56 @@ async def test_get_operation(self):
operations_pb2.GetOperationRequest(name=OPERATION_NAME),
timeout=120
)
+ @pytest.mark.asyncio
+
@mock.patch("airflow.providers.google.cloud.hooks.cloud_run.JobsAsyncClient")
+ async def test_get_conn_uses_async_client_by_default(self,
mock_async_client):
+ """Test that get_conn uses JobsAsyncClient (grpc_asyncio) when
transport is None or grpc."""
+ hook = CloudRunAsyncHook(transport=None)
+ mock_sync_hook = mock.MagicMock()
+ mock_sync_hook.get_credentials.return_value = "credentials"
+ hook.get_sync_hook = mock.AsyncMock(return_value=mock_sync_hook)
+
+ await hook.get_conn()
+
+ mock_async_client.assert_called_once()
+ call_kwargs = mock_async_client.call_args[1]
+ assert "transport" not in call_kwargs
+
+ @pytest.mark.asyncio
+ @mock.patch("airflow.providers.google.cloud.hooks.cloud_run.JobsClient")
+ async def test_get_conn_uses_sync_client_for_rest(self, mock_sync_client):
+ """Test that get_conn uses sync JobsClient with REST transport."""
+ hook = CloudRunAsyncHook(transport="rest")
+ mock_sync_hook = mock.MagicMock()
Review Comment:
Same here, MagicMock(spec=CloudRunServiceHook)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]