This commit is contained in:
2025-05-27 12:15:22 -03:00
parent 270e408c1d
commit 42e62ec183
30 changed files with 287 additions and 178 deletions

View File

@@ -12,7 +12,6 @@ from layercake.dynamodb import (
PartitionKey,
PrefixKey,
SortKey,
TransactItems,
TransactKey,
serialize,
)
@@ -94,24 +93,25 @@ def test_transact_write_items(
):
class EmailConflictError(Exception): ...
transact = TransactItems(dynamodb_persistence_layer.table_name)
transact.put(item=KeyPair('5OxmMjL-ujoR5IMGegQz', '0'))
transact.put(item=KeyPair('cpf', '07879819908'))
transact.put(
item=KeyPair('email', 'sergio@somosbeta.com.br'),
cond_expr='attribute_not_exists(sk)',
)
transact.put(
item=KeyPair(
'5OxmMjL-ujoR5IMGegQz',
ComposeKey('sergio@somosbeta.com.br', 'emails'),
),
cond_expr='attribute_not_exists(sk)',
exc_cls=EmailConflictError,
)
with dynamodb_persistence_layer.transact_items() as transact:
# transact = TransactItems(dynamodb_persistence_layer.table_name)
transact.put(item=KeyPair('5OxmMjL-ujoR5IMGegQz', '0'))
transact.put(item=KeyPair('cpf', '07879819908'))
transact.put(
item=KeyPair('email', 'sergio@somosbeta.com.br'),
cond_expr='attribute_not_exists(sk)',
)
transact.put(
item=KeyPair(
'5OxmMjL-ujoR5IMGegQz',
ComposeKey('sergio@somosbeta.com.br', 'emails'),
),
cond_expr='attribute_not_exists(sk)',
exc_cls=EmailConflictError,
)
with pytest.raises(EmailConflictError):
dynamodb_persistence_layer.transact_write_items(transact)
with pytest.raises(EmailConflictError):
transact.write_items()
def test_collection_get_item(