from http import HTTPMethod, HTTPStatus

from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair

from .conftest import HttpApiProxy, LambdaContext

enrollment_id = '845fe390-e3c3-4514-97f8-c42de0566cf0'
body = {
    'data': {
        'name': enrollment_id,
        'slug': 'jzNV3ZrF6T16tX',
        'combined_document_url': 'https://docs.eduseg.com.br/file/WyI3MGVhNGQwYS02YTE5LTQyYzItODgyNy1iZTc0Zjc2ZTlkNmUiLCJibG9iIiwxNzYyMjEwMjg2XQ--72caad853fdc1c64c5321368c7d883828be0b859ed39689355bac9dffe71b8e2/e249c51b-3e68-42eb-bb4b-20659263ce1c.pdf',
    },
}


def test_postback(
    app,
    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='/',
            method=HTTPMethod.POST,
            body=body,
        ),
        lambda_context,
    )
    assert r['statusCode'] == HTTPStatus.NO_CONTENT

    r = dynamodb_persistence_layer.get_item(
        KeyPair('845fe390-e3c3-4514-97f8-c42de0566cf0', '0')
    )
    print(r)
