GithubHelp home page GithubHelp logo

satheler / pytest-minio-mock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oussjarrousse/pytest-minio-mock

0.0 0.0 0.0 208 KB

A pytest plugin designed to simplify testing of applications that interact with Minio

License: Other

Python 100.00%

pytest-minio-mock's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.