"""Generate fake lamba event containing SNS Topic events.""" def generate_records(messages): """Create many fake SNS Topic messages in one Lambda event. Args: messages (list): array of tuples representing SNS Endpoint events Returns: object: fake Lambda event trigger """ return { 'Records': [generate_message(x[0], x[1]) for x in messages] } def generate_message(endpoint_arn, message_type): """Create SNS Endpoint message inside SNS Topic message. Args: endpoint_arn (str): fake endpoint arn value message_type (str): fake SNS Endpoint message type Returns: object: fake SNS Topic message """ return { 'EventSource': 'aws:sns', 'EventVersion': '1.0', 'EventSubscriptionArn': '', 'Sns': { 'Type': 'Notification', 'MessageId': '', 'TopicArn': '', 'Subject': 'DeliveryFailure event for app', 'Message': '{\"DeliveryAttempts\":1,\"EndpointArn\":\"%s\",\"EventType\":\"%s\",\"FailureMessage\":\"Platform token associated with the endpoint is not valid\",\"FailureType\":\"InvalidPlatformToken\",\"MessageId\":\"\",\"Resource\":\"\",\"Service\":\"SNS\",\"Time\":\"\"}' % (endpoint_arn, message_type), # noqa:E501 'Timestamp': '', 'SignatureVersion': '1', 'Signature': '', 'SigningCertUrl': '', 'UnsubscribeUrl': '', 'MessageAttributes': {} } }