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' | |
dynamodb = boto3.resource('dynamodb', 'us-east-1') | |
table = dynamodb.create_table( | |
TableName=table_name, | |
KeySchema=[{'AttributeName': 'user_id', 'KeyType': 'HASH'}], | |
AttributeDefinitions=[{'AttributeName': 'user_id','AttributeType': 'S'}], | |
ProvisionedThroughput={'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5} | |
) | |
response = lambda_handler(event=kinesis_test_event, context={}) | |
table = dynamodb.Table(table_name) | |
response = table.get_item( | |
Key={ | |
'user_id': 'B9B3022F98Fjvjs83AB8a80C185D' | |
} | |
) | |
item = response['Item'] | |
# {'user_id': 'B9B3022F98Fjvjs83AB8a80C185D', 'amount': Decimal('10'), 'updated_at': '2020-08-13T21:44:50.908455'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment