40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import app.events.stopgap.patch_enroll as app
|
|
from aws_lambda_powertools.utilities.typing import LambdaContext
|
|
from layercake.dynamodb import (
|
|
DynamoDBPersistenceLayer,
|
|
SortKey,
|
|
TransactKey,
|
|
)
|
|
|
|
|
|
def test_enroll(
|
|
dynamodb_seeds,
|
|
dynamodb_client,
|
|
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
event = {
|
|
'detail': {
|
|
'new_image': {
|
|
'id': '47ZxxcVBjvhDS5TE98tpfQ',
|
|
'sk': '0',
|
|
'course': {
|
|
'id': '57',
|
|
'name': 'NR-33 Supervisor em Espaço Confinado',
|
|
'time_in_days': 360,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
assert app.lambda_handler(event, lambda_context) # type: ignore
|
|
|
|
result = dynamodb_persistence_layer.collection.get_items(
|
|
TransactKey('47ZxxcVBjvhDS5TE98tpfQ')
|
|
+ SortKey('0')
|
|
+ SortKey('metadata#deduplication_window')
|
|
+ SortKey('metadata#course')
|
|
)
|
|
|
|
assert 'metadata#course' in result
|
|
assert 'metadata#deduplication_window' in result
|