Skip to content

Commit

Permalink
add test for delete job (apache#36933)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgeo authored Jan 21, 2024
1 parent f3cc5f5 commit 77f9f02
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/providers/google/cloud/hooks/test_cloud_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pytest
from google.cloud.run_v2 import (
CreateJobRequest,
DeleteJobRequest,
GetJobRequest,
Job,
ListJobsRequest,
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_update_job(self, mock_batch_service_client, cloud_run_hook):
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
Expand Down Expand Up @@ -247,6 +248,17 @@ def test_list_jobs_with_limit_less_than_zero(self, mock_batch_service_client, cl
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):
Expand Down

0 comments on commit 77f9f02

Please sign in to comment.