[Glue] Implement batch_get_jobs (#6241)
This commit is contained in:
parent
a08174405f
commit
c6b048695b
@ -863,6 +863,13 @@ class GlueBackend(BaseBackend):
|
||||
crawlers.append(crawler.as_dict())
|
||||
return crawlers
|
||||
|
||||
def batch_get_jobs(self, job_names: List[str]) -> List[Dict[str, Any]]:
|
||||
jobs = []
|
||||
for job_name in job_names:
|
||||
if job_name in self.jobs:
|
||||
jobs.append(self.jobs[job_name].as_dict())
|
||||
return jobs
|
||||
|
||||
|
||||
class FakeDatabase(BaseModel):
|
||||
def __init__(self, database_name: str, database_input: Dict[str, Any]):
|
||||
|
@ -524,5 +524,16 @@ class GlueResponse(BaseResponse):
|
||||
}
|
||||
)
|
||||
|
||||
def batch_get_jobs(self) -> str:
|
||||
job_names = self._get_param("JobNames")
|
||||
jobs = self.glue_backend.batch_get_jobs(job_names)
|
||||
jobs_not_found = list(set(job_names) - set(map(lambda job: job["Name"], jobs)))
|
||||
return json.dumps(
|
||||
{
|
||||
"Jobs": jobs,
|
||||
"JobsNotFound": jobs_not_found,
|
||||
}
|
||||
)
|
||||
|
||||
def get_partition_indexes(self) -> str:
|
||||
return json.dumps({"PartitionIndexDescriptorList": []})
|
||||
|
@ -233,6 +233,17 @@ def test_list_jobs_next_token_logic_does_not_create_infinite_loop():
|
||||
assert not next_token
|
||||
|
||||
|
||||
@mock_glue
|
||||
def test_batch_get_jobs():
|
||||
client = create_glue_client()
|
||||
job_name = create_test_job(client)
|
||||
|
||||
response = client.batch_get_jobs(JobNames=[job_name, "job-not-found"])
|
||||
|
||||
assert len(response["Jobs"]) == 1
|
||||
assert len(response["JobsNotFound"]) == 1
|
||||
|
||||
|
||||
def create_glue_client():
|
||||
return boto3.client("glue", region_name="us-east-1")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user