From 5d408ed1e19bc60071762fc991940ce344ae6fef Mon Sep 17 00:00:00 2001 From: cjackal Date: Sun, 30 Jul 2023 01:28:13 +0900 Subject: [PATCH] Set AWS credentials --- py-polars/tests/unit/io/test_cloud.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/py-polars/tests/unit/io/test_cloud.py b/py-polars/tests/unit/io/test_cloud.py index 61585b90a6221..791e1dd7990d4 100644 --- a/py-polars/tests/unit/io/test_cloud.py +++ b/py-polars/tests/unit/io/test_cloud.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os from typing import TYPE_CHECKING import pytest @@ -12,14 +13,18 @@ port = 5000 -endpoint_url = "127.0.0.1" +host = "127.0.0.1" region = "us-east-1" files = ["small.parquet"] @pytest.fixture() def _s3_base() -> ThreadedMotoServer: - moto_server = ThreadedMotoServer(endpoint_url, port) + if "AWS_ACCESS_KEY_ID" not in os.environ: + os.environ["AWS_ACCESS_KEY_ID"] = "accesskey" + if "AWS_SECRET_ACCESS_KEY" not in os.environ: + os.environ["AWS_SECRET_ACCESS_KEY"] = "secretkey" + moto_server = ThreadedMotoServer(host, port) moto_server.start() print("server up") yield @@ -32,7 +37,7 @@ def _s3(_s3_base: ThreadedMotoServer, io_files_path: Path) -> None: import boto3 client = boto3.client( - "s3", region_name=region, endpoint_url=f"http://{endpoint_url}:{port}" + "s3", region_name=region, endpoint_url=f"http://{host}:{port}" ) client.create_bucket(Bucket="bucket") for file in files: @@ -53,6 +58,6 @@ def test_err_on_s3_glob() -> None: def test_scan_parquet_on_s3() -> None: df = pl.scan_parquet( "s3://bucket/small.parquet", - storage_options={"endpoint_url": f"http://{endpoint_url}:{port}"}, + storage_options={"endpoint_url": f"http://{host}:{port}"}, ) assert df.collect().shape == (4, 3)