add layercake
This commit is contained in:
0
layercake/tests/__init__.py
Normal file
0
layercake/tests/__init__.py
Normal file
7
layercake/tests/conftest.py
Normal file
7
layercake/tests/conftest.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import boto3
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dynamodb_client():
|
||||
return boto3.client('dynamodb', endpoint_url='http://127.0.0.1:8000')
|
||||
37
layercake/tests/test_dynamodb.py
Normal file
37
layercake/tests/test_dynamodb.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, TransactItems
|
||||
|
||||
|
||||
def test_transact_write_items(dynamodb_client):
|
||||
user_layer = DynamoDBPersistenceLayer('pytest', dynamodb_client)
|
||||
transact = TransactItems(user_layer.table_name)
|
||||
transact.put(
|
||||
item={
|
||||
'id': '5OxmMjL-ujoR5IMGegQz',
|
||||
'sk': '0',
|
||||
}
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': 'cpf',
|
||||
'sk': '07879819908',
|
||||
}
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': 'email',
|
||||
'sk': 'sergio@somosbeta.com.br',
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': '5OxmMjL-ujoR5IMGegQz',
|
||||
'sk': 'email:sergio@somosbeta.com.br',
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
with pytest.raises(ClientError):
|
||||
user_layer.transact_write_items(transact)
|
||||
Reference in New Issue
Block a user