from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import (
    DynamoDBPersistenceLayer,
    PartitionKey,
)

import events.schedule_reminders as app


def test_schedule_reminders(
    seeds,
    dynamodb_persistence_layer: DynamoDBPersistenceLayer,
    lambda_context: LambdaContext,
):
    event = {
        'detail': {
            'new_image': {
                'id': '14682b79-3df2-4351-9229-8b558af046a0',
                'sk': '0',
                'user': {
                    'id': '1234',
                    'name': 'Ozzy Osbourne',
                    'email': 'ozzy@osbourne.com',
                },
                'course': {
                    'id': '12334',
                    'name': 'pytest',
                },
            }
        }
    }
    assert app.lambda_handler(event, lambda_context)  # type: ignore

    r = dynamodb_persistence_layer.collection.query(
        PartitionKey('14682b79-3df2-4351-9229-8b558af046a0')
    )
    assert len(r['items']) == 3
