Skip to content

Commit

Permalink
Set AWS credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
cjackal committed Jul 29, 2023
1 parent 07ab954 commit 5d408ed
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions py-polars/tests/unit/io/test_cloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
from typing import TYPE_CHECKING

import pytest
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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)

0 comments on commit 5d408ed

Please sign in to comment.