66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
from aws_lambda_powertools.utilities.typing import LambdaContext
|
|
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, PartitionKey
|
|
|
|
import events.start_fulfillment as app
|
|
|
|
|
|
def test_fulfillment_enrollments(
|
|
dynamodb_seeds,
|
|
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
order_id = '9b9441d2-4ae3-4b50-8cb6-71e872d4492a'
|
|
org_id = 'fee6f09b-e9fe-468d-b783-3dea5279d4dc'
|
|
event = {
|
|
'detail': {
|
|
'new_image': {
|
|
'id': order_id,
|
|
'sk': 'FULFILLMENT',
|
|
'org_id': org_id,
|
|
'status': 'IN_PROGRESS',
|
|
}
|
|
}
|
|
}
|
|
|
|
assert app.lambda_handler(event, lambda_context) # type: ignore
|
|
|
|
r = dynamodb_persistence_layer.collection.query(
|
|
KeyPair(order_id, 'ENROLLMENT#'),
|
|
)
|
|
assert len(r['items']) == 3
|
|
|
|
seats = dynamodb_persistence_layer.collection.query(
|
|
PartitionKey(f'SEAT#ORG#{org_id}')
|
|
)
|
|
assert len(seats['items']) == 1
|
|
|
|
scheduled = dynamodb_persistence_layer.collection.query(
|
|
PartitionKey(f'SCHEDULED#ORG#{org_id}')
|
|
)
|
|
assert len(scheduled['items']) == 1
|
|
|
|
|
|
def test_fulfillment_items(
|
|
dynamodb_seeds,
|
|
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
org_id = 'fee6f09b-e9fe-468d-b783-3dea5279d4dc'
|
|
event = {
|
|
'detail': {
|
|
'new_image': {
|
|
'id': '9f7fa055-7c0b-418a-b023-77477d1895b9',
|
|
'sk': 'FULFILLMENT',
|
|
'org_id': org_id,
|
|
'status': 'IN_PROGRESS',
|
|
}
|
|
}
|
|
}
|
|
|
|
assert app.lambda_handler(event, lambda_context) # type: ignore
|
|
|
|
seats = dynamodb_persistence_layer.collection.query(
|
|
PartitionKey(f'SEAT#ORG#{org_id}')
|
|
)
|
|
assert len(seats['items']) == 2
|