From 1c5c5036e364140fe979660b499cce73a344edb7 Mon Sep 17 00:00:00 2001 From: Stephan Huber Date: Mon, 24 Sep 2018 13:04:39 +0200 Subject: [PATCH] fixing errors on get_job_document --- moto/iot/responses.py | 2 +- tests/test_iot/test_iot.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/moto/iot/responses.py b/moto/iot/responses.py index 0d3677925..c71d4942a 100644 --- a/moto/iot/responses.py +++ b/moto/iot/responses.py @@ -153,7 +153,7 @@ class IoTResponse(BaseResponse): job = self.iot_backend.get_job_document(job_id=self._get_param("jobId")) if job.document is not None: - json.dumps({'document': job.document}) + return json.dumps({'document': job.document}) else: # job.document_source is not None: # TODO: needs to be implemented to get document_source's content from S3 diff --git a/tests/test_iot/test_iot.py b/tests/test_iot/test_iot.py index 1f2305360..759c7d3c7 100644 --- a/tests/test_iot/test_iot.py +++ b/tests/test_iot/test_iot.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import json +import sure # noqa import boto3 @@ -555,7 +556,10 @@ def test_create_job(): client = boto3.client('iot', region_name='eu-west-1') name = "my-thing" job_id = "TestJob" - # thing + # thing# job document + # job_document = { + # "field": "value" + # } thing = client.create_thing(thingName=name) thing.should.have.key('thingName').which.should.equal(name) thing.should.have.key('thingArn') @@ -718,16 +722,21 @@ def test_get_job_document_with_document_source(): def test_get_job_document_with_document(): client = boto3.client('iot', region_name='eu-west-1') name = "my-thing" - job_id = "TestJob1" + job_id = "TestJob" # thing thing = client.create_thing(thingName=name) thing.should.have.key('thingName').which.should.equal(name) thing.should.have.key('thingArn') + # job document + job_document = { + "field": "value" + } + job = client.create_job( jobId=job_id, targets=[thing["thingArn"]], - document=json.dumps({'foo': 'bar'}), + document=json.dumps(job_document), presignedUrlConfig={ 'roleArn': 'arn:aws:iam::1:role/service-role/iot_job_role', 'expiresInSec': 123 @@ -742,4 +751,4 @@ def test_get_job_document_with_document(): job.should.have.key('jobArn') job_document = client.get_job_document(jobId=job_id) - job_document.should.have.key('document').which.should.equal('') + job_document.should.have.key('document').which.should.equal("{\"field\": \"value\"}")