add test
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from http import HTTPMethod, HTTPStatus
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey
|
||||
|
||||
from ..conftest import HttpApiProxy, LambdaContext
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_preexisting_user(
|
||||
assert r['statusCode'] == HTTPStatus.OK
|
||||
|
||||
|
||||
def test_preexisting_update_email(
|
||||
def test_preexisting_user_conflict(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
@@ -58,6 +58,47 @@ def test_preexisting_update_email(
|
||||
assert r['statusCode'] == HTTPStatus.CONFLICT
|
||||
|
||||
|
||||
def test_preexisting_user_update_email(
|
||||
app,
|
||||
seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
r = app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/register',
|
||||
method=HTTPMethod.POST,
|
||||
body={
|
||||
'id': '357db1c5-7442-4075-98a3-fbe5c938a419',
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'cpf': '07879819908',
|
||||
'password': 'Led@Zepellin',
|
||||
'email': 'osergiosiqueira+pytest@gmail.com',
|
||||
},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
assert r['statusCode'] == HTTPStatus.OK
|
||||
|
||||
user = dynamodb_persistence_layer.collection.get_items(
|
||||
TransactKey(
|
||||
'357db1c5-7442-4075-98a3-fbe5c938a419',
|
||||
)
|
||||
+ SortKey('0')
|
||||
+ SortKey('emails#osergiosiqueira+pytest@gmail.com')
|
||||
+ SortKey('emails#sergio@somosbeta.com.br'),
|
||||
flatten_top=False,
|
||||
)
|
||||
assert user['0']['email'] == 'osergiosiqueira+pytest@gmail.com'
|
||||
assert 'emails#osergiosiqueira+pytest@gmail.com' in user
|
||||
assert 'emails#sergio@somosbeta.com.br' in user
|
||||
assert user['0']['emails'] == {
|
||||
'sergio@somosbeta.com.br',
|
||||
'osergiosiqueira+pytest@gmail.com',
|
||||
}
|
||||
|
||||
|
||||
def test_non_preexisting_user(
|
||||
app,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
|
||||
Reference in New Issue
Block a user