fix enroll and reenroll relationship
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from datetime import timedelta
|
||||
|
||||
import app.events.cert_reporting.append_cert as app
|
||||
import app.events.reporting.append_cert as app
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import (
|
||||
@@ -1,4 +1,4 @@
|
||||
import app.events.cert_reporting.send_report_email as app
|
||||
import app.events.reporting.send_report_email as app
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
@@ -1,6 +1,6 @@
|
||||
import app.events.enroll as app
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
|
||||
|
||||
def test_enroll(
|
||||
@@ -8,12 +8,26 @@ def test_enroll(
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
order_id = 'cpYSbBcie2NDbZhDKCxCih'
|
||||
event = {
|
||||
'detail': {
|
||||
'new_image': {
|
||||
'id': 'cpYSbBcie2NDbZhDKCxCih',
|
||||
'id': order_id,
|
||||
'sk': 'generated_items',
|
||||
}
|
||||
}
|
||||
}
|
||||
assert app.lambda_handler(event, lambda_context) # type: ignore
|
||||
|
||||
# Parent knows the child
|
||||
order_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
KeyPair(order_id, 'LINKED_ENTITIES#ORDER#CHILD')
|
||||
)
|
||||
assert order_entity
|
||||
|
||||
# Child knows the parent
|
||||
enrollment_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
KeyPair(order_entity['enrollment_id'], 'LINKED_ENTITIES#ORDER#PARENT'),
|
||||
)
|
||||
|
||||
assert enrollment_entity['order_id'] == order_id
|
||||
|
||||
@@ -30,19 +30,19 @@ def test_reenroll(
|
||||
assert app.lambda_handler(event, lambda_context) # type: ignore
|
||||
|
||||
# Parent knows the child
|
||||
child_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
current_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
KeyPair(
|
||||
pk=parent_id,
|
||||
sk='LINKED_ENTITIES#ENROLLMENT#CHILD',
|
||||
)
|
||||
)
|
||||
assert child_entity
|
||||
assert current_entity
|
||||
|
||||
# Child knows the parent
|
||||
parent_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
new_entity = dynamodb_persistence_layer.collection.get_item(
|
||||
KeyPair(
|
||||
pk=child_entity['enrollment_id'],
|
||||
pk=current_entity['enrollment_id'],
|
||||
sk='LINKED_ENTITIES#ENROLLMENT#PARENT',
|
||||
)
|
||||
)
|
||||
assert parent_entity['enrollment_id'] == parent_id
|
||||
assert new_entity['enrollment_id'] == parent_id
|
||||
|
||||
Reference in New Issue
Block a user