-1

我需要帮助编写 python 模拟单元测试用例以使用 lambda 触发 AWS Glue 作业。请帮我。下面是示例代码

# Set up logging
 import json
 import os
 import logging
 logger = logging.getLogger()
 logger.setLevel(logging.INFO)

 # Import Boto 3 for AWS Glue
 import boto3
 client = boto3.client('glue')

 # Variables for the job: 
 glueJobName = "MyTestJob"

 # Define Lambda function
 def lambda_handler(event, context):
  logger.info('## TRIGGERED BY EVENT: ')

  logger.info(event['detail'])
  response = 
  client.start_job_run(JobName = glueJobName)
  logger.info('## STARTED GLUE JOB: ' + glueJobName)
  logger.info('## GLUE JOB RUN ID: ' + response['JobRunId'])
  return response

请帮忙。

4

1 回答 1

0

这是类似问题的答案:https ://stackoverflow.com/a/61480045/11305581

简而言之,您需要来自 boto3 客户端的模拟低级 API 响应,或者moto如果该功能已在那里实现,则使用包。

于 2020-05-09T18:59:58.240 回答