47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
from http import HTTPMethod, HTTPStatus
|
|
|
|
from layercake.dynamodb import DynamoDBPersistenceLayer, SortKey, TransactKey
|
|
|
|
from .conftest import HttpApiProxy, LambdaContext
|
|
|
|
order_id = '121c1140-779d-4664-8d99-4a006a22f547'
|
|
|
|
|
|
def test_postback(
|
|
app,
|
|
dynamodb_seeds,
|
|
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
|
http_api_proxy: HttpApiProxy,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
# This data was added from seeds
|
|
r = app.lambda_handler(
|
|
http_api_proxy(
|
|
raw_path=f'/{order_id}/postback',
|
|
method=HTTPMethod.POST,
|
|
body=(
|
|
'event=invoice.status_changed&'
|
|
'data[id]=RDBBACE5DE174554BA2C836E96D751AA&'
|
|
'data[status]=paid&'
|
|
'data[account_id]=AF01CF1B3451459F92666F10589278EE&'
|
|
'data[payment_method]=iugu_credit_card&'
|
|
'data[paid_at]=2022-10-17T18:21:55-03:00&'
|
|
'data[paid_cents]=10255&'
|
|
'data[order_id]=cPqkdJUeqqCB6WATsSWnsZ'
|
|
),
|
|
is_base64_encoded=True,
|
|
headers={'content-type': 'application/x-www-form-urlencoded'},
|
|
),
|
|
lambda_context,
|
|
)
|
|
assert r['statusCode'] == HTTPStatus.NO_CONTENT
|
|
|
|
order = dynamodb_persistence_layer.collection.get_items(
|
|
TransactKey(order_id)
|
|
+ SortKey('0')
|
|
+ SortKey('FULFILLMENT', rename_key='fulfillment')
|
|
)
|
|
assert 'fulfillment' in order
|
|
|
|
assert order['status'] == 'PAID'
|