ytoprakc commented on code in PR #61790:
URL: https://github.com/apache/airflow/pull/61790#discussion_r2800751554


##########
providers/google/tests/unit/google/cloud/operators/test_gen_ai.py:
##########
@@ -152,6 +165,36 @@ def test_execute(self, mock_hook):
             config=None,
         )
 
+    @mock.patch(GEN_AI_PATH.format("GenAIGenerativeModelHook"))
+    def test_execute_propagates_client_error(self, mock_hook, 
mock_client_error):
+        op = GenAIGenerateEmbeddingsOperator(
+            task_id=TASK_ID,
+            project_id=GCP_PROJECT,
+            location=GCP_LOCATION,
+            contents=CONTENTS,
+            model=EMBEDDING_MODEL,
+            gcp_conn_id=GCP_CONN_ID,
+            impersonation_chain=IMPERSONATION_CHAIN,
+        )
+
+        mock_hook.return_value.embed_content.side_effect = mock_client_error
+
+        with pytest.raises(ClientError):
+            op.execute(context={"ti": mock.MagicMock()})
+
+        mock_hook.assert_called_once_with(
+            gcp_conn_id=GCP_CONN_ID,
+            impersonation_chain=IMPERSONATION_CHAIN,
+        )
+
+        mock_hook.return_value.embed_content.assert_called_once_with(
+            project_id=GCP_PROJECT,
+            location=GCP_LOCATION,
+            contents=CONTENTS,
+            model=EMBEDDING_MODEL,
+            config=None,
+        )
+
 
 class TestGenAIGenerateContentOperator:

Review Comment:
   Yes, I have left out `TestGenAIGenerateContentOperator` as well as 
`GenAIGeminiListBatchJobsOperator`, `GenAICountTokensOperator` as they are 
being worked on by others in https://github.com/apache/airflow/issues/61261.



-- 
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]

Reply via email to