View lambda_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
import base64 | |
from datetime import datetime | |
import requests | |
def lambda_handler(event, context): | |
for record in event['Records']: |
View test_lambda_function_hollow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from lambda_function import * | |
def test_lambda_handler(): | |
try: | |
response = lambda_handler({'Records': []}, {}) | |
except Exception as e: | |
print(e) |
View lambda_pytest_fixtures.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'})) |
View test_lambda_function_fix.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from lambda_function import * | |
import base64 | |
import json | |
@pytest.fixture | |
def kinesis_test_event(): | |
kinesis_event = { | |
"Records": [ | |
{ |
View lambda_function_amateur.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
View lambda_function_pro.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
import traceback | |
import json | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def lambda_handler(event, context): | |
'''Simple Lambda function.''' |
View aws_lambda_logging_format.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
)) |
View test_lambda_function_events.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from lambda_function import * | |
test_kinesis_event = { | |
"Records": [ | |
{ | |
"kinesis": { | |
base64.b64encode(json.dumps({'a': 'dog', 'b': 'cat'})) | |
} | |
}]} |
View test_lambda_function_moto_dynamo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import pytest | |
from moto import mock_dynamodb2 | |
from lambda_function import * | |
@mock_dynamodb2 | |
def test_lambda_handler(): | |
table_name = 'user_spending' |
View test_lambda_function_moto_s3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import pytest | |
from moto import mock_s3 | |
from lambda_function import * | |
@mock_s3 | |
def test_lambda_handler(): |
OlderNewer