Ejemplo n.º 1
0
    from basket.list import list

if 'ENV' in os.environ:
    from get import get
else:
    from basket.get import get

logger = logging.getLogger()

if __name__ == "__main__":
    from uuid import uuid4
    import random
    # Tests the model against a local DynamoDB
    # docker run --rm -p 8000:8000 amazon/dynamodb-local:latest

    if not Basket.exists():
        Basket.create_table(read_capacity_units=100,
                            write_capacity_units=100,
                            wait=True)

    customer_id = str(uuid4())

    print('###Test creating basket')
    for x in range(1, 6):
        item = {
            "customer_id": customer_id,
            "product_id": str(x),
            "price": random.uniform(0.99, 10.99),
            "quantity": random.randint(1, 10)
        }
        event = {'body': json.dumps(item)}