| 1 |
import boto3 |
| 2 |
import pytest |
| 3 |
|
| 4 |
from conda_package_streaming import s3 |
| 5 |
|
| 6 |
LIMIT = 16 |
| 7 |
|
| 8 |
|
| 9 |
@pytest.fixture |
| 10 |
def s3_client(package_server): |
| 11 |
host, port = package_server.server.server_address |
| 12 |
client = boto3.client( |
| 13 |
"s3", |
| 14 |
aws_access_key_id="test_id", |
| 15 |
aws_secret_access_key="test_key", |
| 16 |
endpoint_url=f"http://{host}:{port}", |
| 17 |
use_ssl=False, |
| 18 |
verify=False, |
| 19 |
) |
| 20 |
return client |
| 21 |
|
| •22 |
@pytest.mark.skip(reason="Conda is not yet available for Debian") |
| 23 |
def test_head_objects(s3_client, conda_paths): |
| 24 |
bucket = "pkgs" # independent of filesystem path |
| 25 |
for path in conda_paths[:LIMIT]: |
| 26 |
s3_client.head_object(Bucket=bucket, Key=path.name) |
| 27 |
|
| •28 |
@pytest.mark.skip(reason="Conda is not yet available for Debian") |
| 29 |
def test_stream_s3(s3_client, conda_paths): |
| 30 |
with pytest.raises(ValueError): |
| 31 |
next(s3.stream_conda_info(s3_client, "pkgs", "notaconda.rar")) |
| 32 |
|
| 33 |
for path in conda_paths[:LIMIT]: |
| 34 |
members = s3.stream_conda_info(s3_client, "pkgs", path.name) |
| 35 |
print("stream s3", path.name) |
| 36 |
for tar, member in members: |
| 37 |
if member.name == "info/index.json": |
| 38 |
members.close() # faster than waiting for gc? |
| 39 |
break |
| 40 |
else: |
| 41 |
pytest.fail("info/index.json not found") |