This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 77f9f02865 add test for delete job (#36933)
77f9f02865 is described below
commit 77f9f02865a6fe0ceb0b408bab3bbaef5c32438a
Author: Kevin George <[email protected]>
AuthorDate: Sun Jan 21 02:14:43 2024 -0500
add test for delete job (#36933)
---
tests/providers/google/cloud/hooks/test_cloud_run.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tests/providers/google/cloud/hooks/test_cloud_run.py
b/tests/providers/google/cloud/hooks/test_cloud_run.py
index 0a1436075e..04a683ada5 100644
--- a/tests/providers/google/cloud/hooks/test_cloud_run.py
+++ b/tests/providers/google/cloud/hooks/test_cloud_run.py
@@ -22,6 +22,7 @@ from unittest import mock
import pytest
from google.cloud.run_v2 import (
CreateJobRequest,
+ DeleteJobRequest,
GetJobRequest,
Job,
ListJobsRequest,
@@ -70,7 +71,7 @@ class TestCloudRunHook:
region = "region1"
project_id = "projectid"
job = Job()
- job.name = job.name =
f"projects/{project_id}/locations/{region}/jobs/{job_name}"
+ job.name = f"projects/{project_id}/locations/{region}/jobs/{job_name}"
update_request = UpdateJobRequest()
update_request.job = job
@@ -247,6 +248,17 @@ class TestCloudRunHook:
with pytest.raises(expected_exception=AirflowException):
cloud_run_hook.list_jobs(region=region, project_id=project_id,
limit=limit)
+ @mock.patch("airflow.providers.google.cloud.hooks.cloud_run.JobsClient")
+ def test_delete_job(self, mock_batch_service_client, cloud_run_hook):
+ job_name = "job1"
+ region = "region1"
+ project_id = "projectid"
+
+ delete_request =
DeleteJobRequest(name=f"projects/{project_id}/locations/{region}/jobs/{job_name}")
+
+ cloud_run_hook.delete_job(job_name=job_name, region=region,
project_id=project_id)
+
cloud_run_hook._client.delete_job.assert_called_once_with(delete_request)
+
def _mock_pager(self, number_of_jobs):
mock_pager = []
for i in range(number_of_jobs):