diff --git a/moto/iot/models.py b/moto/iot/models.py index ad0e459f7..0e86f93d2 100644 --- a/moto/iot/models.py +++ b/moto/iot/models.py @@ -1306,7 +1306,7 @@ class IoTBackend(BaseBackend): if status is not None: job_executions = list( filter( - lambda elem: status in elem["status"] and elem["status"] == status, + lambda elem: elem["jobExecutionSummary"].get("status") == status, job_executions, ) ) @@ -1338,7 +1338,7 @@ class IoTBackend(BaseBackend): if status is not None: job_executions = list( filter( - lambda elem: status in elem["status"] and elem["status"] == status, + lambda elem: elem["jobExecutionSummary"].get("status") == status, job_executions, ) ) diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py index d4505df1a..ac77bdaa6 100644 --- a/tests/test_iot/test_iot.py +++ b/tests/test_iot/test_iot.py @@ -2011,6 +2011,12 @@ def test_list_job_executions_for_job(): "thingArn" ).which.should.equal(thing["thingArn"]) + job_execution = client.list_job_executions_for_job(jobId=job_id, status="QUEUED") + job_execution.should.have.key("executionSummaries") + job_execution["executionSummaries"][0].should.have.key( + "thingArn" + ).which.should.equal(thing["thingArn"]) + @mock_iot def test_list_job_executions_for_thing(): @@ -2048,6 +2054,14 @@ def test_list_job_executions_for_thing(): job_id ) + job_execution = client.list_job_executions_for_thing( + thingName=name, status="QUEUED" + ) + job_execution.should.have.key("executionSummaries") + job_execution["executionSummaries"][0].should.have.key("jobId").which.should.equal( + job_id + ) + class TestTopicRules: name = "my-rule"