Merge pull request '[patch] update dependencies' (#16) from renovate/auto-deps-update into main
Reviewed-on: https://gitea.lille-vemmelund.dk/brian/python-repositories/pulls/16
This commit was merged in pull request #16.
This commit is contained in:
@@ -24,6 +24,8 @@ repos:
|
||||
rev: v1.8.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
- types-redis
|
||||
|
||||
# Python syntax modernization with pyupgrade
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
|
||||
@@ -131,7 +131,7 @@ class MinioAdapter(
|
||||
if not isinstance(content_type, str) or len(content_type) == 0:
|
||||
raise ValueError("content_type must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Prepare buffer for reading
|
||||
num_bytes = data.getbuffer().nbytes
|
||||
@@ -156,7 +156,7 @@ class MinioAdapter(
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
raise ValueError("object_name must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Get data from bucket
|
||||
# N.B. bucket name is set when connecting
|
||||
@@ -191,7 +191,7 @@ class MinioAdapter(
|
||||
if not isinstance(object_name, str) or len(object_name) == 0:
|
||||
raise ValueError("object_name must be a non-empty string")
|
||||
# Check connection
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# Delete object from bucket
|
||||
# N.B. bucket name is set when connecting
|
||||
@@ -210,7 +210,7 @@ class MinioAdapter(
|
||||
raise ValueError("prefix must be a string")
|
||||
# Check connection
|
||||
# N.B. bucket name is set when connecting
|
||||
if self._client is None or not self.is_connected:
|
||||
if self._client is None or self._bucket_name is None or not self.is_connected:
|
||||
raise ConnectionError("Not connected to Minio")
|
||||
# List objects in bucket
|
||||
objects = self._client.list_objects(
|
||||
|
||||
@@ -9,6 +9,7 @@ import random
|
||||
import os
|
||||
import logging
|
||||
from minio import S3Error
|
||||
from urllib3.response import BaseHTTPResponse
|
||||
from python_repositories.adapters.minio_adapter import MinioAdapter
|
||||
from python_repositories.interfaces import ObjectRepositoryInterface
|
||||
|
||||
@@ -42,7 +43,7 @@ def same_data(
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def data() -> Generator[BytesIO]:
|
||||
def data() -> Generator[BytesIO, None, None]:
|
||||
"""Provide a sample data bytes for tests."""
|
||||
# Generate random bytes
|
||||
random_bytes = random.randbytes(2**21) # 2 MiB
|
||||
@@ -53,7 +54,7 @@ def data() -> Generator[BytesIO]:
|
||||
def data_in_minio(
|
||||
raw_minio_client: Minio,
|
||||
data: BytesIO,
|
||||
) -> Generator[tuple[str, BytesIO]]:
|
||||
) -> Generator[tuple[str, BytesIO], None, None]:
|
||||
"""Fixture to set up a known value in Minio before each test."""
|
||||
object_name = "test_object"
|
||||
bucket_name = str(os.getenv("MINIO_BUCKET"))
|
||||
@@ -77,7 +78,7 @@ def data_in_minio(
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def minio_adapter() -> Generator[MinioAdapter]:
|
||||
def minio_adapter() -> Generator[MinioAdapter, None, None]:
|
||||
"""Fixture to provide a connected MinioAdapter instance."""
|
||||
adapter = MinioAdapter()
|
||||
adapter.connect()
|
||||
@@ -234,12 +235,12 @@ def test_should_log_warning_when_getting_nonexistent_object(
|
||||
adapter = MinioAdapter()
|
||||
adapter._client = MagicMock(spec=Minio)
|
||||
adapter._client.get_object.side_effect = S3Error(
|
||||
code="NoSuchKey",
|
||||
message="",
|
||||
resource="",
|
||||
request_id="",
|
||||
host_id="",
|
||||
response="",
|
||||
MagicMock(spec=BaseHTTPResponse),
|
||||
"NoSuchKey",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
bucket_name="test-bucket",
|
||||
object_name="missing-object",
|
||||
)
|
||||
@@ -264,12 +265,12 @@ def test_should_log_error_when_getting_with_s3error_other_than_no_such_key(
|
||||
adapter = MinioAdapter()
|
||||
adapter._client = MagicMock(spec=Minio)
|
||||
other_s3error = S3Error(
|
||||
code="UnhandledError",
|
||||
message="",
|
||||
resource="",
|
||||
request_id="",
|
||||
host_id="",
|
||||
response="",
|
||||
MagicMock(spec=BaseHTTPResponse),
|
||||
"UnhandledError",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
bucket_name="test-bucket",
|
||||
object_name="missing-object",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user