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

import events.send_reminder_emails as app


def test_reminder_access_period_before_30_days(
    seeds,
    dynamodb_persistence_layer: DynamoDBPersistenceLayer,
    lambda_context: LambdaContext,
):
    app.send_email = lambda *args, **kwargs: ...

    pk = '47ZxxcVBjvhDS5TE98tpfQ'
    sk = 'SCHEDULE#REMINDER_ACCESS_PERIOD_BEFORE_30_DAYS'
    event = {
        'detail': {
            'old_image': {
                'id': pk,
                'sk': sk,
            }
        }
    }

    assert app.lambda_handler(event, lambda_context)  # type: ignore

    r = dynamodb_persistence_layer.collection.get_item(KeyPair(pk, f'{sk}#EXECUTED'))
    assert r
