Reputation: 99
I need help for writing python mock unit test case to trigger AWS Glue job using lambda. Please help me. Below is the sample code
# 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
Please help.
Upvotes: 1
Views: 8297
Reputation: 3387
Here's answer to similar question: https://stackoverflow.com/a/61480045/11305581
In short, you need mock low-level API response from boto3 client or use moto
package if this functionality has been implemented there.
Upvotes: 1