Skip to content

Instantly share code, notes, and snippets.

View peacing's full-sized avatar

Paul Singman peacing

View GitHub Profile
import pytest
from lambda_function import *
def test_lambda_handler():
try:
response = lambda_handler({'Records': []}, {})
except Exception as e:
print(e)
@peacing
peacing / lambda_function.py
Last active July 28, 2020 00:50
example lambda function
import json
import boto3
import base64
from datetime import datetime
import requests
def lambda_handler(event, context):
for record in event['Records']:
import base64
import json
@pytest.fixture
def kinesis_test_event():
kinesis_event = {
"Records": [
{
"kinesis": {
base64.b64encode(json.dumps({'artist': 'Lana Del Rey', 'track': 'Brooklyn Baby'}))
import pytest
from lambda_function import *
import base64
import json
@pytest.fixture
def kinesis_test_event():
kinesis_event = {
"Records": [
{
@peacing
peacing / lambda_function_amateur.py
Last active August 3, 2020 02:08
Amateur Lambda Function
def lambda_handler(event, context):
'''Simple Lambda function. event = {'artist': 'Lana Del Rey'}
'''
try:
print(f'event: {event}')
artist = event['artist']
print(f'The artist is: {artist}')
return {"status": "success", "message": None}
import logging
logger_handler.setFormatter(logging.Formatter(
'[%(levelname)s]\t%(asctime)s.%(msecs)dZ\t%(aws_request_id)s\t%(message)s\n',
'%Y-%m-%dT%H:%M:%S'
))
import pytest
from lambda_function import *
test_kinesis_event = {
"Records": [
{
"kinesis": {
base64.b64encode(json.dumps({'a': 'dog', 'b': 'cat'}))
}
}]}
import boto3
import pytest
from moto import mock_s3
from lambda_function import *
@mock_s3
def test_lambda_handler():
import boto3
import pytest
from lambda_function import *
class MockBotoSession:
class Session:
def client(self, service_name, region_name):
# create a flexible Client class for any boto3 client
class Client:
import boto3
import json
import pytest
from moto import mock_dynamodb2
from lambda_function import *
@pytest.fixture
def test_sqs_event():
test_sqs_event = {