improve report

This commit is contained in:
2025-10-15 21:38:37 -03:00
parent ffa04d9b15
commit 6455feb4fa
15 changed files with 160 additions and 130 deletions

View File

@@ -39,9 +39,9 @@ def test_append_cert(
assert app.lambda_handler(event, lambda_context) # type: ignore
# The reporting month is the month before the certificate expires
month_start = (cert_expires_at.replace(day=1) - timedelta(days=1)).replace(day=1)
report_month = (cert_expires_at.replace(day=1) - timedelta(days=1)).replace(day=1)
report_sk = 'MONTH#{}#SCHEDULE#SEND_REPORT_EMAIL'.format(
month_start.strftime('%Y-%m')
report_month.strftime('%Y-%m')
)
r = dynamodb_persistence_layer.collection.get_items(

View File

@@ -2,6 +2,7 @@ import app.events.reporting.send_report_email as app
from aws_lambda_powertools.utilities.typing import LambdaContext
from layercake.dynamodb import (
DynamoDBPersistenceLayer,
KeyPair,
)
@@ -11,10 +12,11 @@ def test_send_report_email(
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
lambda_context: LambdaContext,
):
pk = 'CERT#REPORTING#ORG#00237409-9384-4692-9be5-b4443a41e1c4'
event = {
'detail': {
'old_image': {
'id': 'CERT#REPORTING#ORG#00237409-9384-4692-9be5-b4443a41e1c4',
'id': pk,
'sk': 'MONTH#2025-06#SCHEDULE#SEND_REPORT_EMAIL',
'target_month': '2025-07',
},
@@ -23,3 +25,6 @@ def test_send_report_email(
monkeypatch.setattr(app.sesv2_client, 'send_email', lambda *args, **kwargs: ...)
assert app.lambda_handler(event, lambda_context) # type: ignore
r = dynamodb_persistence_layer.collection.get_item(KeyPair(pk, 'MONTH#2025-06'))
assert r['status'] == 'CLOSED'