shahar1 commented on code in PR #44425:
URL: https://github.com/apache/airflow/pull/44425#discussion_r1863777955


##########
providers/tests/google/cloud/hooks/test_cloud_batch.py:
##########
@@ -97,8 +97,12 @@ def test_delete_job(self, mock_batch_service_client, 
cloud_batch_hook):
     def test_wait_job_succeeded(self, mock_batch_service_client, state, 
cloud_batch_hook):
         mock_job = self._mock_job_with_status(state)
         mock_batch_service_client.return_value.get_job.return_value = mock_job
-        actual_job = cloud_batch_hook.wait_for_job("job1")
-        assert actual_job == mock_job
+        if state != JobStatus.State.SUCCEEDED:
+            with pytest.raises(AirflowException):
+                cloud_batch_hook.wait_for_job("job1")
+        else:
+            actual_job = cloud_batch_hook.wait_for_job("job1")
+            assert actual_job == mock_job

Review Comment:
   I think that it's better to avoid having `if`s within a unit test, as each 
statement simulates an essentially different behavior (i.e., deserves its own 
unit test).
   Could you please split it into two different tests? You could keep this one 
for the `JobStatus.State.SUCCEEDED` (disabling the parameterization), and have 
another test (`test_wait_job_not_succeeded` mayybe?) for both 
`JobStatus.State.FAILED, JobStatus.State.DELETION_IN_PROGRESS`.



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