remove prefix

This commit is contained in:
2025-05-22 16:54:43 -03:00
parent a51723f64f
commit 585bcfcc2a
5 changed files with 38 additions and 24 deletions

View File

@@ -3,5 +3,5 @@
{"id": {"S": "logs#5OxmMjL-ujoR5IMGegQz"}, "sk": {"S": "2024-02-08T16:42:33.776409-03:00"}, "action": {"S": "OPEN_EMAIL"}}
{"id": {"S": "logs#5OxmMjL-ujoR5IMGegQz"}, "sk": {"S": "2019-03-25T00:00:00-03:00"}, "action": {"S": "CLICK_EMAIL"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "0"}, "name": {"S": "EDUSEG"}, "cnpj": {"S": "15608435000190"}, "email": {"S": "org+15608435000190@users.noreply.betaeducacao.com.br"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "payment_policy"}, "due_days": {"N": "90"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "billing_policy"}, "billing_day": {"N": "1"}, "payment_method": {"S": "PIX"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "metadata#payment_policy"}, "due_days": {"N": "90"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "metadata#billing_policy"}, "billing_day": {"N": "1"}, "payment_method": {"S": "PIX"}}

View File

@@ -111,9 +111,8 @@ def test_transact_write_items(
exc_cls=EmailConflictError,
)
with pytest.raises(EmailConflictError) as exc:
with pytest.raises(EmailConflictError):
dynamodb_persistence_layer.transact_write_items(transact)
# print(exc.value)
def test_collection_get_item(
@@ -257,8 +256,8 @@ def test_collection_get_items(
doc = collect.get_items(
TransactKey('cJtK9SsnJhKPyxESe7g3DG')
+ SortKey('0')
+ SortKey('billing_policy', path_spec='payment_method')
+ SortKey('payment_policy'),
+ SortKey('metadata#billing_policy', path_spec='payment_method')
+ SortKey('metadata#payment_policy', remove_prefix='metadata#'),
)
assert doc == {
@@ -267,7 +266,7 @@ def test_collection_get_items(
'id': 'cJtK9SsnJhKPyxESe7g3DG',
'cnpj': '15608435000190',
'email': 'org+15608435000190@users.noreply.betaeducacao.com.br',
'billing_policy': 'PIX',
'metadata#billing_policy': 'PIX',
'payment_policy': {'due_days': Decimal('90')},
}
@@ -280,12 +279,15 @@ def test_collection_get_items_unflatten(
doc = collect.get_items(
TransactKey('cJtK9SsnJhKPyxESe7g3DG')
+ SortKey('billing_policy')
+ SortKey('payment_policy'),
+ SortKey('metadata#billing_policy')
+ SortKey('metadata#payment_policy', remove_prefix='metadata#'),
flatten_top=False,
)
assert doc == {
'billing_policy': {'billing_day': Decimal('1'), 'payment_method': 'PIX'},
'metadata#billing_policy': {
'billing_day': Decimal('1'),
'payment_method': 'PIX',
},
'payment_policy': {'due_days': Decimal('90')},
}