from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair

import events.stopgap.set_as_paid as app


def test_set_as_paid(
    dynamodb_seeds,
    dynamodb_persistence_layer: DynamoDBPersistenceLayer,
    lambda_context: LambdaContext,
):
    event = {
        'detail': {
            'new_image': {
                'id': '9omWNKymwU5U4aeun6mWzZ',
            }
        }
    }
    assert app.lambda_handler(event, lambda_context)  # type: ignore

    doc = dynamodb_persistence_layer.get_item(
        key=KeyPair('9omWNKymwU5U4aeun6mWzZ', '0'),
    )
    assert doc['status'] == 'PAID'
