jykae commented on code in PR #67333:
URL: https://github.com/apache/airflow/pull/67333#discussion_r3308936954


##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_job.py:
##########
@@ -883,29 +903,73 @@ def test_execute_complete_pod_not_found_skips_logs(self, 
mock_hook, mocked_write
         mocked_write_logs.assert_not_called()
 
     @pytest.mark.non_db_test_override
+    @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.pod_manager"), 
new_callable=mock.PropertyMock)
     @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator._write_logs"))
     @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.hook"))
-    def test_execute_complete_pod_api_error_reraises(self, mock_hook, 
mocked_write_logs):
-        """Non-404 ApiExceptions should still be raised."""
-        from kubernetes.client.rest import ApiException
+    def test_execute_complete_pod_api_error_does_not_raise(
+        self, mock_hook, mocked_write_logs, mock_pod_manager_prop
+    ):
+        """Non-404 errors fetching the monitoring pod must not fail 
``execute_complete``.
 
-        mock_ti = mock.MagicMock()
-        context = {"ti": mock_ti}
-        mock_job = mock.MagicMock()
+        Cleanup is best-effort: log writing is skipped, but the pod is still
+        targeted for deletion by name so it doesn't outlive the job.
+        """
+        pm = _recording_pod_manager()
+        mock_pod_manager_prop.return_value = pm
+        mock_hook.get_pod.side_effect = ApiException(status=403, 
reason="Forbidden")
         event = {
-            "job": mock_job,
+            "job": mock.MagicMock(),
             "status": "success",

Review Comment:
   fixed



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