83 lines
2.2 KiB
Python
83 lines
2.2 KiB
Python
import json
|
|
from http import HTTPMethod, HTTPStatus
|
|
|
|
from layercake.dynamodb import DynamoDBPersistenceLayer
|
|
|
|
from ..conftest import HttpApiProxy, LambdaContext
|
|
|
|
|
|
def test_preexisting_user(
|
|
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': 'sergio@somosbeta.com.br',
|
|
},
|
|
),
|
|
lambda_context,
|
|
)
|
|
|
|
assert r['statusCode'] == HTTPStatus.OK
|
|
|
|
|
|
def test_preexisting_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@gmail.com',
|
|
},
|
|
),
|
|
lambda_context,
|
|
)
|
|
body = json.loads(r['body'])
|
|
|
|
assert body['type'] == 'EmailConflictError'
|
|
assert r['statusCode'] == HTTPStatus.CONFLICT
|
|
|
|
|
|
def test_non_preexisting_user(
|
|
app,
|
|
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': '14ddcef6-483c-4181-bdb2-3e9a31a24732',
|
|
'name': 'David Bowie',
|
|
'cpf': '23355097055',
|
|
'password': 'Ziggy@Stardust',
|
|
'email': 'david@bowie.com',
|
|
},
|
|
),
|
|
lambda_context,
|
|
)
|
|
|
|
assert r['statusCode'] == HTTPStatus.CREATED
|