diff --git a/IMPLEMENTATION_COVERAGE.md b/IMPLEMENTATION_COVERAGE.md index c602ce7b1..7bd4458ab 100644 --- a/IMPLEMENTATION_COVERAGE.md +++ b/IMPLEMENTATION_COVERAGE.md @@ -2391,7 +2391,7 @@ ## ecs
-80% implemented +78% implemented - [X] create_capacity_provider - [X] create_cluster @@ -2402,6 +2402,7 @@ - [X] delete_capacity_provider - [X] delete_cluster - [X] delete_service +- [ ] delete_task_definitions - [X] delete_task_set - [X] deregister_container_instance - [X] deregister_task_definition @@ -3197,7 +3198,7 @@ - [ ] get_job_bookmark - [X] get_job_run - [ ] get_job_runs -- [ ] get_jobs +- [X] get_jobs - [ ] get_mapping - [ ] get_ml_task_run - [ ] get_ml_task_runs @@ -6880,6 +6881,7 @@ - support-app - synthetics - timestream-query +- tnb - transfer - translate - voice-id diff --git a/docs/docs/services/ecs.rst b/docs/docs/services/ecs.rst index c3ddd7d99..735415407 100644 --- a/docs/docs/services/ecs.rst +++ b/docs/docs/services/ecs.rst @@ -36,6 +36,7 @@ ecs - [X] delete_capacity_provider - [X] delete_cluster - [X] delete_service +- [ ] delete_task_definitions - [X] delete_task_set The Force-parameter is not yet implemented diff --git a/docs/docs/services/glue.rst b/docs/docs/services/glue.rst index 219f6b80c..b3a559923 100644 --- a/docs/docs/services/glue.rst +++ b/docs/docs/services/glue.rst @@ -124,7 +124,7 @@ glue - [ ] get_job_bookmark - [X] get_job_run - [ ] get_job_runs -- [ ] get_jobs +- [X] get_jobs - [ ] get_mapping - [ ] get_ml_task_run - [ ] get_ml_task_runs diff --git a/moto/__init__.py b/moto/__init__.py index 18d8a72d9..b25359aba 100644 --- a/moto/__init__.py +++ b/moto/__init__.py @@ -88,7 +88,7 @@ mock_firehose = lazy_load(".firehose", "mock_firehose") mock_forecast = lazy_load(".forecast", "mock_forecast") mock_greengrass = lazy_load(".greengrass", "mock_greengrass") mock_glacier = lazy_load(".glacier", "mock_glacier") -mock_glue = lazy_load(".glue", "mock_glue") +mock_glue = lazy_load(".glue", "mock_glue", boto3_name="glue") mock_guardduty = lazy_load(".guardduty", "mock_guardduty") mock_iam = lazy_load(".iam", "mock_iam") mock_iot = lazy_load(".iot", "mock_iot") diff --git a/moto/backend_index.py b/moto/backend_index.py index 7e2831c35..7dc48e205 100644 --- a/moto/backend_index.py +++ b/moto/backend_index.py @@ -1,4 +1,4 @@ -# autogenerated by /Users/danaronson/GitHub/forks/moto/scripts/update_backend_index.py +# autogenerated by /Users/dan/Sites/moto/scripts/update_backend_index.py import re backend_url_patterns = [ diff --git a/moto/glue/models.py b/moto/glue/models.py index 70e794f49..3194f4cb5 100644 --- a/moto/glue/models.py +++ b/moto/glue/models.py @@ -69,6 +69,12 @@ class GlueBackend(BaseBackend): "limit_default": 100, "unique_attribute": "name", }, + "get_jobs": { + "input_token": "next_token", + "limit_key": "max_results", + "limit_default": 100, + "unique_attribute": "name", + }, } def __init__(self, region_name, account_id): @@ -329,6 +335,10 @@ class GlueBackend(BaseBackend): except KeyError: raise JobNotFoundException(name) + @paginate(pagination_model=PAGINATION_MODEL) + def get_jobs(self): + return [job for _, job in self.jobs.items()] + def start_job_run(self, name): job = self.get_job(name) return job.start_job_run() diff --git a/moto/glue/responses.py b/moto/glue/responses.py index fd797d6c2..64ddd107c 100644 --- a/moto/glue/responses.py +++ b/moto/glue/responses.py @@ -343,6 +343,19 @@ class GlueResponse(BaseResponse): job = self.glue_backend.get_job(name) return json.dumps({"Job": job.as_dict()}) + def get_jobs(self): + next_token = self._get_param("NextToken") + max_results = self._get_int_param("MaxResults") + jobs, next_token = self.glue_backend.get_jobs( + next_token=next_token, max_results=max_results + ) + return json.dumps( + dict( + Jobs=[job.as_dict() for job in jobs], + NextToken=next_token, + ) + ) + def start_job_run(self): name = self.parameters.get("JobName") job_run_id = self.glue_backend.start_job_run(name) diff --git a/tests/test_glue/test_glue.py b/tests/test_glue/test_glue.py index 507b7affc..820bbc14e 100644 --- a/tests/test_glue/test_glue.py +++ b/tests/test_glue/test_glue.py @@ -109,6 +109,53 @@ def test_get_job_exists(): job.should.have.key("GlueVersion") +@mock_glue +def test_get_jobs_job_name_exists(): + client = create_glue_client() + test_job_name = create_test_job(client) + response = client.get_jobs() + response["Jobs"].should.have.length_of(1) + response["Jobs"][0].should.have.key("Name").equals(test_job_name) + + +@mock_glue +def test_get_jobs_with_max_results(): + client = create_glue_client() + create_test_jobs(client, 4) + response = client.get_jobs(MaxResults=2) + response["Jobs"].should.have.length_of(2) + response.should.have.key("NextToken") + + +@mock_glue +def test_get_jobs_from_next_token(): + client = create_glue_client() + create_test_jobs(client, 10) + first_response = client.get_jobs(MaxResults=3) + response = client.get_jobs(NextToken=first_response["NextToken"]) + response["Jobs"].should.have.length_of(7) + + +@mock_glue +def test_get_jobs_with_max_results_greater_than_actual_results(): + client = create_glue_client() + create_test_jobs(client, 4) + response = client.get_jobs(MaxResults=10) + response["Jobs"].should.have.length_of(4) + + +@mock_glue +def test_get_jobs_next_token_logic_does_not_create_infinite_loop(): + client = create_glue_client() + create_test_jobs(client, 4) + first_response = client.get_jobs(MaxResults=1) + next_token = first_response["NextToken"] + while next_token: + response = client.get_jobs(NextToken=next_token) + next_token = response.get("NextToken") + assert not next_token + + @mock_glue def test_list_jobs_with_max_results(): client = create_glue_client()