def testWithoutParameters(self): '''APIGateway.createResponse() should create a response with statusCode 200, the Access-Control-Allow-Origin header and a body with an empty JSON if called without parameters''' event = {} sut = APIGateway(mockLoggerFactory, event) response = sut.createResponse() self.assertEqual(response, {'statusCode': 200, 'headers': {'Access-Control-Allow-Origin': '*'}, 'body': '{}'})
def testWithAllParameters(self): '''APIGateway.createResponse() should create a response with the passed statusCode, the Access-Control-Allow-Origin header added to the passed headers and the conversiont to json of the passed body as body''' event = {} sut = APIGateway(mockLoggerFactory, event) body = {'this': {'is': {'the': 'body'}}} response = sut.createResponse(123, {'h': 'header'}, body) self.assertEqual(response, { 'statusCode': 123, 'headers': {'Access-Control-Allow-Origin': '*', 'h': 'header'}, 'body': json.dumps(body, default=jsonutils.dumpdefault) })