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

import events.billing.send_email_on_closing as app


def test_send_email_on_closing(
    monkeypatch,
    dynamodb_seeds,
    dynamodb_persistence_layer: DynamoDBPersistenceLayer,
    lambda_context: LambdaContext,
):
    event = {
        'detail': {
            'new_image': {
                'id': 'BILLING#ORG#cJtK9SsnJhKPyxESe7g3DG',
                'sk': 'START#2025-07-01#END#2025-07-31',
                'status': 'CLOSED',
                's3_uri': 's3://saladeaula.digital/billing/sample.pdf',
            },
        }
    }
    monkeypatch.setattr(app.sesv2_client, 'send_email', lambda *args, **kwargs: ...)

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