A pytest plugin for mocking Minio S3 interactions
Project description
pytest-minio-mock
Overview
pytest-minio-mock
is a pytest plugin designed to simplify testing of applications that interact with Minio the code S3 compatible object storage system. It is not designed to test the correnction to the minio server. It provides a fixture that mocks the minio.Minio
class, allowing for easy testing of Minio interactions without the need for a real Minio server.
Features
- Mock implementation of the
minio.Minio
client. - Easy to use pytest fixture.
- Supports common Minio operations such as bucket creation, file upload/download, etc.
Installation
To install pytest-minio-mock
, run:
pip install pytest-minio-mock
Usage
To use the minio_mock fixture in your pytest tests, simply include it as a parameter in your test functions. Then use minio.Minio() as usual Here's an example:
def foo():
try:
minio_client = minio.Minio(
endpoint=S3_URI,
access_key=S3_ACCESS_KEY,
secret_key=S3_SECRET_KEY,
region=S3_REGION
)
minio_client.make_bucket("buckets")
except Exception as e:
logging.error(e)
def test_file_upload(minio_mock):
# Calling function foo that involves using minio.Minio()
assert foo()
The minio_mock
fixture will patch minio.Minio() thus providing you with a way to test your code around the Minio client easily.
API
MockMinioClient
A brief description of the mocked methods and their behavior, like:
make_bucket(bucket_name, ...)
# Mocks bucket creation.fput_object(bucket_name, object_name, file_path, ...)
# Mocks file upload.- ...
Contributing
Contributions to pytest-minio-mock are welcome! The Contributing Guide is still under construction.
License
pytest-minio-mock is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_minio_mock-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7774e06fb46610c52b37cf72ffdd399c3463638b71ca0f748425f0767e543ba9 |
|
MD5 | a1694e790e4c805dbeda13f56be27d9e |
|
BLAKE2b-256 | c17d46054ee8bc0bb48d46bca19f5785ea2ea61e03757cd90aab8313aa796a34 |