add get_items

This commit is contained in:
2025-04-08 13:44:06 -03:00
parent 68ff6f282b
commit 6450e5fa7c
18 changed files with 393 additions and 195 deletions

View File

@@ -1,4 +1,5 @@
from datetime import datetime
from decimal import Decimal
from ipaddress import IPv4Address
import pytest
@@ -12,7 +13,9 @@ from layercake.dynamodb import (
KeyPair,
PartitionKey,
PrefixKey,
SortKey,
TransactItems,
TransactKey,
serialize,
)
@@ -189,14 +192,14 @@ def test_collection_delete_item(
)
def test_collection_get_items(
def test_collection_query(
dynamodb_seeds,
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
):
collect = DynamoDBCollection(dynamodb_persistence_layer)
# This data was added from seeds
logs = collect.get_items(
logs = collect.query(
PartitionKey(
ComposeKey('5OxmMjL-ujoR5IMGegQz', prefix='logs'),
),
@@ -219,7 +222,7 @@ def test_collection_get_items(
}
# This data was added from seeds
emails = collect.get_items(
emails = collect.query(
KeyPair('5OxmMjL-ujoR5IMGegQz', PrefixKey('emails')),
)
assert emails == {
@@ -236,3 +239,27 @@ def test_collection_get_items(
],
'last_key': None,
}
def test_collection_get_items(
dynamodb_seeds,
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
):
collect = DynamoDBCollection(dynamodb_persistence_layer)
doc = collect.get_items(
TransactKey('cJtK9SsnJhKPyxESe7g3DG')
+ SortKey('0')
+ SortKey('billing_policy')
+ SortKey('payment_policy')
)
assert doc == {
'sk': '0',
'name': 'EDUSEG',
'id': 'cJtK9SsnJhKPyxESe7g3DG',
'cnpj': '15608435000190',
'email': 'org+15608435000190@users.noreply.betaeducacao.com.br',
'billing_policy': {'billing_day': Decimal('1'), 'payment_method': 'PIX'},
'payment_policy': {'due_days': Decimal('90')},
}