logger = logging.getLogger() xray.patch_all() secrets_manager_client = clients.SecretsManagerClient() clients = { 'appsync': clients.AppSyncClient(), 'cloudfront': clients.CloudFrontClient(secrets_manager_client.get_cloudfront_key_pair), 'dynamo': clients.DynamoClient(), 'mediaconvert': clients.MediaConvertClient(), 'post_verification': clients.PostVerificationClient( secrets_manager_client.get_post_verification_api_creds), 's3_uploads': clients.S3Client(S3_UPLOADS_BUCKET), } managers = {} post_manager = managers.get('post') or models.PostManager(clients, managers=managers) def event_to_extras(event): # Seems the boto s3 client deals with non-urlencoded keys to objects everywhere, but # apparenttly this falls outside that scope. The event emitter passes us a urlencoded path. path = urllib.parse.unquote(event['Records'][0]['s3']['object']['key']) return {'s3_key': path}
def post_verification_client(): # by default, all images pass verification yield mock.Mock(clients.PostVerificationClient(lambda: None), **{'verify_image.return_value': True})