MinIO

Integration with MinIO, an S3-compatible object storage service.

This integration uses the official MinIO Python Client to interact with MinIO, which provides S3-compatible object storage for testing and development.

Installation

pip install pytest-databases[minio]

Docker Image

Official MinIO Docker Image

Configuration

  • MINIO_ACCESS_KEY: Access key for MinIO (default: “minio”)

  • MINIO_SECRET_KEY: Secret key for MinIO (default: “minio123”)

  • MINIO_SECURE: Whether to use HTTPS (default: “false”)

Usage Example

from minio import Minio
from pytest_databases.docker.minio import MinioService

pytest_plugins = ["pytest_databases.docker.minio"]

def test(minio_service: MinioService) -> None:
    client = Minio(
        endpoint=minio_service.endpoint,
        access_key=minio_service.access_key,
        secret_key=minio_service.secret_key,
        secure=minio_service.secure,
    )
    client.make_bucket("test-bucket")
    assert client.bucket_exists("test-bucket")

def test(minio_client: Minio) -> None:
    minio_client.make_bucket("test-bucket")
    assert minio_client.bucket_exists("test-bucket")

Available Fixtures

  • minio_access_key: The access key for MinIO defaults to os.getenv(“MINIO_ACCESS_KEY”, “minio”).

  • minio_secret_key: The secret key for MinIO defaults to os.getenv(“MINIO_SECRET_KEY”, “minio123”).

  • minio_secure: Whether to use HTTPS for MinIO defaults to os.getenv(“MINIO_SECURE”, “false”).

  • minio_service: A fixture that provides a MinIO service.

  • minio_client: A fixture that provides a MinIO client.

  • minio_default_bucket_name: A fixture that provides the default bucket name.

Service API

class pytest_databases.docker.minio.MinioService(host, port, endpoint, access_key, secret_key, secure)[source]

Bases: ServiceContainer

endpoint: str
access_key: str
secret_key: str
secure: bool
__init__(host, port, endpoint, access_key, secret_key, secure)
pytest_databases.docker.minio.minio_access_key()[source]
Return type:

str

pytest_databases.docker.minio.minio_secret_key()[source]
Return type:

str

pytest_databases.docker.minio.minio_secure()[source]
Return type:

bool

pytest_databases.docker.minio.xdist_minio_isolation_level()[source]
Return type:

Literal['database', 'server']

pytest_databases.docker.minio.minio_default_bucket_name(xdist_minio_isolation_level)[source]
Return type:

str

pytest_databases.docker.minio.minio_service(docker_service, minio_access_key, minio_secret_key, minio_secure)[source]
Return type:

Generator[MinioService, None, None]

pytest_databases.docker.minio.minio_client(minio_service, minio_default_bucket_name)[source]
Return type:

Generator[Minio, None, None]