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

import events.allocate_slots as app


def test_allocate_slots(
    seeds,
    dynamodb_persistence_layer: DynamoDBPersistenceLayer,
    lambda_context: LambdaContext,
):
    event = {
        'detail': {
            'new_image': {
                'id': 'JeCybf6oiv6CF3PchhBqdG',
                'sk': 'generated_items',
            }
        }
    }
    assert app.lambda_handler(event, lambda_context)  # type: ignore

    result = dynamodb_persistence_layer.collection.query(
        PartitionKey('vacancies#PWQyjGZeVcoD5zc5eTkvpr')
    )

    assert len(result['items']) == 4
