update orders

This commit is contained in:
2026-01-07 19:04:07 -03:00
parent 3f76273f83
commit d1fc6c602c
23 changed files with 305 additions and 129 deletions

View File

@@ -7,7 +7,7 @@ from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
from ...conftest import HttpApiProxy, LambdaContext
def test_checkout(
def test_checkout_coupon(
app,
seeds,
http_api_proxy: HttpApiProxy,
@@ -23,7 +23,15 @@ def test_checkout(
'cnpj': '00000000000191',
'name': 'Branco do Brasil',
'email': 'bb@users.noreply.saladeaula.digital',
'payment_method': 'BANK_SLIP',
'payment_method': 'CREDIT_CARD',
'installments': 12,
'credit_card': {
'holder_name': 'Sergio R Siqueira',
'number': '4111111111111111',
'exp_month': '01',
'exp_year': '2026',
'cvv': '123',
},
'created_by': {
'id': '15bacf02-1535-4bee-9022-19d106fd7518',
'name': 'Sérgio R Siqueira',
@@ -33,17 +41,59 @@ def test_checkout(
'postcode': '81280350',
'neighborhood': 'Cidade Industrial',
'address1': 'Rua Monsenhor Ivo Zanlorenzi',
'address2': '5190, ap 1802',
'address2': '5190, ap 1802',
'state': 'PR',
},
'items': [
{
'id': 'e1c44881-2fe3-484e-ada2-12b6bf5b9398',
'name': 'NR-35 Segurança nos Trabalhos em Altura',
'quantity': 2,
'unit_price': 119,
}
'name': 'CIPA Grau de Risco 1',
'id': '3c27ea9c-9464-46a1-9717-8c1441793186',
'quantity': 1,
'unit_price': 99,
},
{
'name': 'CIPA Grau de Risco 2',
'id': '99bb3b60-4ded-4a8e-937c-ba2d78ec6454',
'quantity': 1,
'unit_price': 99,
},
],
'enrollments': [
{
'user': {
'name': 'Sérgio Rafael de Siqueira',
'cpf': '07879819908',
'id': '5OxmMjL-ujoR5IMGegQz',
'email': 'sergio@somosbeta.com.br',
},
'course': {
'name': 'CIPA Grau de Risco 1',
'id': '3c27ea9c-9464-46a1-9717-8c1441793186',
'access_period': 365,
},
'id': '2f026d38-1edc-44ea-abf3-60c10bc58909',
},
{
'course': {
'name': 'CIPA Grau de Risco 2',
'id': '99bb3b60-4ded-4a8e-937c-ba2d78ec6454',
'access_period': 365,
},
'scheduled_for': '2026-01-20',
'id': '1f0931ad-7dd4-4ca1-bce2-a2e89efa5b56',
'user': {
'name': 'Maitê L Siqueira',
'cpf': '02186829991',
'id': '87606a7f-de56-4198-a91d-b6967499d382',
'email': 'osergiosiqueira+maite@gmail.com',
},
},
],
'coupon': {
'code': '10OFF',
'type': 'PERCENT',
'amount': 10,
},
},
),
lambda_context,
@@ -56,42 +106,44 @@ def test_checkout(
pprint(r['items'])
# def test_checkout_from_user(
# app,
# seeds,
# http_api_proxy: HttpApiProxy,
# dynamodb_persistence_layer: DynamoDBPersistenceLayer,
# lambda_context: LambdaContext,
# ):
# r = app.lambda_handler(
# http_api_proxy(
# raw_path='/orders',
# method=HTTPMethod.POST,
# body={
# 'user_id': '15bacf02-1535-4bee-9022-19d106fd7518',
# 'cpf': '07879819908',
# 'name': 'Sérgio R Siqueira',
# 'email': 'sergio@somosbeta.com.br',
# 'payment_method': 'MANUAL',
# 'address': {
# 'city': 'Curitiba',
# 'postcode': '81280350',
# 'neighborhood': 'Cidade Industrial',
# 'address1': 'Rua Monsenhor Ivo Zanlorenzi',
# 'address2': 'nº 5190, ap 1802',
# 'state': 'PR',
# },
# 'items': [
# {
# 'id': 'e1c44881-2fe3-484e-ada2-12b6bf5b9398',
# 'name': 'NR-35 Segurança nos Trabalhos em Altura',
# 'quantity': 2,
# 'unit_price': 119,
# }
# ],
# },
# ),
# lambda_context,
# )
# print(r)
# assert r['statusCode'] == HTTPStatus.CREATED
def test_checkout_from_user(
app,
seeds,
http_api_proxy: HttpApiProxy,
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
lambda_context: LambdaContext,
):
r = app.lambda_handler(
http_api_proxy(
raw_path='/orders',
method=HTTPMethod.POST,
body={
'user_id': '15bacf02-1535-4bee-9022-19d106fd7518',
'cpf': '07879819908',
'name': 'Sérgio R Siqueira',
'email': 'sergio@somosbeta.com.br',
'payment_method': 'MANUAL',
'address': {
'sk': 'METADATA#ADDRESS',
'address1': 'Rua Monsenhor Ivo Zanlorenzi',
'address2': '5190, ap 1802',
'postcode': '81280350',
'city': 'Curitiba',
'neighborhood': 'Cidade Industrial',
'state': 'PR',
},
'items': [
{
'id': 'e1c44881-2fe3-484e-ada2-12b6bf5b9398',
'name': 'NR-35 Segurança nos Trabalhos em Altura',
'quantity': 2,
'unit_price': 119,
'access_period': 20,
}
],
},
),
lambda_context,
)
print(r)
assert r['statusCode'] == HTTPStatus.CREATED