-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from oussjarrousse/version-0.4.16
Version 0.4.16
- Loading branch information
Showing
7 changed files
with
138 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,16 @@ | |
|
||
__title__ = "pytest-minio-mock" | ||
__description__ = "A pytest plugin for mocking Minio S3 interactions" | ||
__version__ = "0.4.15" | ||
__version__ = "0.4.16" | ||
__status__ = "Production" | ||
__license__ = "MIT" | ||
__author__ = "Oussama Jarrousse" | ||
__maintainer__ = "Oussama Jarrousse" | ||
__email__ = "[email protected]" | ||
__credits__ = ["Gustavo Satheler", "@cottephi", "Wouter van Atteveldt", "@KelvinHong"] | ||
__credits__ = [ | ||
"Gustavo Satheler", | ||
"@cottephi", | ||
"Wouter van Atteveldt", | ||
"@KelvinHong", | ||
"Tomas Kazmar", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
""" | ||
import pytest | ||
from minio.commonconfig import ENABLED | ||
from minio.versioningconfig import OFF | ||
from minio.versioningconfig import VersioningConfig | ||
|
||
from pytest_minio_mock.plugin import MockMinioBucket | ||
|
||
|
||
@pytest.mark.UNIT | ||
class TestsMockMinioBucket: | ||
@pytest.mark.UNIT | ||
def test_mock_minio_bucket_init(self): | ||
mock_minio_bucket = MockMinioBucket( | ||
bucket_name="test-bucket", versioning=VersioningConfig() | ||
) | ||
assert mock_minio_bucket.bucket_name == "test-bucket" | ||
assert mock_minio_bucket.versioning.status == OFF | ||
assert mock_minio_bucket.objects == {} | ||
|
||
versioning_config = VersioningConfig(ENABLED) | ||
mock_minio_bucket = MockMinioBucket( | ||
bucket_name="test-bucket", versioning=versioning_config | ||
) | ||
assert isinstance(mock_minio_bucket._versioning, VersioningConfig) | ||
assert mock_minio_bucket.versioning.status == ENABLED | ||
|
||
@pytest.mark.UNIT | ||
def test_versioning(self): | ||
mock_minio_bucket = MockMinioBucket( | ||
bucket_name="test-bucket", versioning=VersioningConfig() | ||
) | ||
versioning_config = mock_minio_bucket.versioning | ||
assert isinstance(versioning_config, VersioningConfig) | ||
assert versioning_config.status == OFF | ||
versioning_config = VersioningConfig(status=ENABLED) | ||
mock_minio_bucket.versioning = versioning_config | ||
versioning_config = mock_minio_bucket.versioning | ||
assert isinstance(versioning_config, VersioningConfig) | ||
assert versioning_config.status == ENABLED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
""" | ||
import pytest | ||
|
||
from pytest_minio_mock.plugin import MockMinioClient | ||
|
||
|
||
@pytest.mark.UNIT | ||
class TestsMockMinioClient: | ||
@pytest.mark.UNIT | ||
def test_mock_minio_client_init_with_minimal_parameters(self): | ||
endpoint = "http://localhost:9000" | ||
client = MockMinioClient(endpoint) | ||
assert client._base_url == endpoint | ||
assert client._access_key == None | ||
assert client._secret_key == None | ||
assert client._session_token == None | ||
assert client._secure is True | ||
assert client._region == None | ||
assert client._http_client == None | ||
assert client._credentials == None | ||
assert client._cert_check is True | ||
|
||
@pytest.mark.UNIT | ||
def test_mock_minio_client_init_with_all_params(self): | ||
endpoint = "http://localhost:9000" | ||
access_key = "accessKey" | ||
secret_key = "secretKey" | ||
session_token = "sessionToken" | ||
secure = False | ||
region = "us-east-1" | ||
http_client = "mock_http_client" | ||
credentials = "mock_credentials" | ||
cert_check = False | ||
|
||
client = MockMinioClient( | ||
endpoint, | ||
access_key=access_key, | ||
secret_key=secret_key, | ||
session_token=session_token, | ||
secure=secure, | ||
region=region, | ||
http_client=http_client, | ||
credentials=credentials, | ||
cert_check=cert_check, | ||
) | ||
|
||
assert client._base_url == endpoint, "Endpoint should be stored correctly" | ||
assert client._access_key == access_key, "Access key should be stored correctly" | ||
assert client._secret_key == secret_key, "Secret key should be stored correctly" | ||
assert ( | ||
client._session_token == session_token | ||
), "Session token should be stored correctly" | ||
assert client._secure == secure, "Secure should reflect the passed value" | ||
assert client._region == region, "Region should be stored correctly" | ||
assert ( | ||
client._http_client == http_client | ||
), "HTTP client should be stored correctly" | ||
assert ( | ||
client._credentials == credentials | ||
), "Credentials should be stored correctly" | ||
assert client._cert_check == cert_check | ||
|
||
@pytest.mark.UNIT | ||
def test_mock_minio_client_init_error_handling(self): | ||
with pytest.raises( | ||
TypeError, match="missing 1 required positional argument: 'endpoint'" | ||
): | ||
client = MockMinioClient() # not passing endpoint should raise an error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
""" | ||
import pytest | ||
|
||
from pytest_minio_mock.plugin import MockMinioObject | ||
|
||
|
||
@pytest.mark.UNIT | ||
class TestsMockMinioObject: | ||
@pytest.mark.UNIT | ||
def test_mock_minio_object_init(self): | ||
mock_minio_object = MockMinioObject("test-bucket", "test-object") | ||
assert mock_minio_object.versions == {} |