Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-django-minio-storage for
openSUSE:Factory checked in at 2023-05-08 17:24:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-minio-storage (Old)
and /work/SRC/openSUSE:Factory/.python-django-minio-storage.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-minio-storage"
Mon May 8 17:24:12 2023 rev:7 rq:1085339 version:0.5.2
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-django-minio-storage/python-django-minio-storage.changes
2023-04-24 22:31:11.111500632 +0200
+++
/work/SRC/openSUSE:Factory/.python-django-minio-storage.new.1533/python-django-minio-storage.changes
2023-05-08 17:24:14.372679475 +0200
@@ -1,0 +2,7 @@
+Sun May 7 18:53:24 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 0.5.2:
+ * Add/fix more type hints.
+ * Fix type hints
+
+-------------------------------------------------------------------
Old:
----
django-minio-storage-0.5.0.tar.gz
New:
----
django-minio-storage-0.5.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-django-minio-storage.spec ++++++
--- /var/tmp/diff_new_pack.oUkJub/_old 2023-05-08 17:24:14.936682809 +0200
+++ /var/tmp/diff_new_pack.oUkJub/_new 2023-05-08 17:24:14.940682833 +0200
@@ -20,7 +20,7 @@
%bcond_with test
%define skip_python2 1
Name: python-django-minio-storage
-Version: 0.5.0
+Version: 0.5.2
Release: 0
Summary: Django file storage using minio
License: Apache-2.0 OR MIT
++++++ django-minio-storage-0.5.0.tar.gz -> django-minio-storage-0.5.2.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/.editorconfig
new/django-minio-storage-0.5.2/.editorconfig
--- old/django-minio-storage-0.5.0/.editorconfig 2023-04-23
13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/.editorconfig 2023-05-06
06:01:34.000000000 +0200
@@ -13,3 +13,9 @@
[.travis.yml]
indent_style = space
indent_size = 2
+
+[*.json]
+charset = utf-8
+indent_style = space
+indent_size = 2
+max_line_length = 88
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/CHANGELOG.md
new/django-minio-storage-0.5.2/CHANGELOG.md
--- old/django-minio-storage-0.5.0/CHANGELOG.md 2023-04-23 13:01:14.000000000
+0200
+++ new/django-minio-storage-0.5.2/CHANGELOG.md 2023-05-06 06:01:34.000000000
+0200
@@ -1,3 +1,11 @@
+## 0.5.2
+
+Add/fix more type hints.
+
+## 0.5.1
+
+Fix type hints
+
## 0.5.0
Switched the minio-py client library version from `<7` to `>=7`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/PKG-INFO
new/django-minio-storage-0.5.2/PKG-INFO
--- old/django-minio-storage-0.5.0/PKG-INFO 2023-04-23 13:01:30.946837400
+0200
+++ new/django-minio-storage-0.5.2/PKG-INFO 2023-05-06 06:01:56.595380500
+0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: django-minio-storage
-Version: 0.5.0
+Version: 0.5.2
Summary: Django file storage using the minio python client
Home-page: https://github.com/py-pa/django-minio-storage
Author: Tom Houlé
@@ -21,8 +21,10 @@
License-File: LICENSE-MIT
[](https://badge.fury.io/py/django-minio-storage)
+[](https://pypistats.org/packages/django-minio-storage)
[](http://django-minio-storage.readthedocs.io/en/latest/?badge=latest)
+
# django-minio-storage
Use [minio](https://minio.io) for django static and media file storage.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/README.md
new/django-minio-storage-0.5.2/README.md
--- old/django-minio-storage-0.5.0/README.md 2023-04-23 13:01:14.000000000
+0200
+++ new/django-minio-storage-0.5.2/README.md 2023-05-06 06:01:34.000000000
+0200
@@ -1,6 +1,8 @@
[](https://badge.fury.io/py/django-minio-storage)
+[](https://pypistats.org/packages/django-minio-storage)
[](http://django-minio-storage.readthedocs.io/en/latest/?badge=latest)
+
# django-minio-storage
Use [minio](https://minio.io) for django static and media file storage.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/django_minio_storage.egg-info/PKG-INFO
new/django-minio-storage-0.5.2/django_minio_storage.egg-info/PKG-INFO
--- old/django-minio-storage-0.5.0/django_minio_storage.egg-info/PKG-INFO
2023-04-23 13:01:30.000000000 +0200
+++ new/django-minio-storage-0.5.2/django_minio_storage.egg-info/PKG-INFO
2023-05-06 06:01:56.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: django-minio-storage
-Version: 0.5.0
+Version: 0.5.2
Summary: Django file storage using the minio python client
Home-page: https://github.com/py-pa/django-minio-storage
Author: Tom Houlé
@@ -21,8 +21,10 @@
License-File: LICENSE-MIT
[](https://badge.fury.io/py/django-minio-storage)
+[](https://pypistats.org/packages/django-minio-storage)
[](http://django-minio-storage.readthedocs.io/en/latest/?badge=latest)
+
# django-minio-storage
Use [minio](https://minio.io) for django static and media file storage.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/django_minio_storage.egg-info/SOURCES.txt
new/django-minio-storage-0.5.2/django_minio_storage.egg-info/SOURCES.txt
--- old/django-minio-storage-0.5.0/django_minio_storage.egg-info/SOURCES.txt
2023-04-23 13:01:30.000000000 +0200
+++ new/django-minio-storage-0.5.2/django_minio_storage.egg-info/SOURCES.txt
2023-05-06 06:01:56.000000000 +0200
@@ -13,6 +13,7 @@
docs-requirements.txt
mkdocs.yml
pyproject.toml
+pyrightconfig.json
setup.py
tox.ini
.github/workflows/release.yml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/minio_storage/files.py
new/django-minio-storage-0.5.2/minio_storage/files.py
--- old/django-minio-storage-0.5.0/minio_storage/files.py 2023-04-23
13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/minio_storage/files.py 2023-05-06
06:01:34.000000000 +0200
@@ -8,7 +8,7 @@
from minio_storage.errors import minio_error
if T.TYPE_CHECKING:
- from minio_storage.storage import Storage
+ from minio_storage.storage import MinioStorage
logger = getLogger("minio_storage")
@@ -36,8 +36,8 @@
class MinioStorageFile(File):
- def __init__(self, name: str, mode: str, storage: "Storage", **kwargs):
- self._storage: "Storage" = storage
+ def __init__(self, name: str, mode: str, storage: "MinioStorage",
**kwargs):
+ self._storage: "MinioStorage" = storage
self.name: str = name
self._mode: str = mode
self._file = None
@@ -46,15 +46,13 @@
class ReadOnlyMinioObjectFile(MinioStorageFile, ReadOnlyMixin,
NonSeekableMixin):
"""A django File class which directly exposes the underlying minio object.
This
means the the instance doesnt support functions like .seek() and is
required to
- be closed to be able to reuse minio connections.
-
- Note: This file class is not tested yet"""
+ be closed to be able to reuse minio connections."""
def __init__(
self,
name: str,
mode: str,
- storage: "Storage",
+ storage: "MinioStorage",
max_memory_size: T.Optional[int] = None,
**kwargs,
):
@@ -66,7 +64,9 @@
self.max_memory_size = max_memory_size
super().__init__(name, mode, storage)
- def _get_file(self):
+ @property
+ def file(self):
+ obj = None
if self._file is None:
try:
obj = self._storage.client.get_object(
@@ -79,16 +79,16 @@
raise OSError(f"File {self.name} does not exist")
finally:
try:
- obj.release_conn()
+ if obj:
+ obj.release_conn()
except Exception as e:
logger.error(str(e))
return self._file
+ @file.setter
def _set_file(self, value):
self._file = value
- file = property(_get_file, _set_file)
-
def close(self):
try:
self.file.close()
@@ -106,7 +106,7 @@
self,
name: str,
mode: str,
- storage: "Storage",
+ storage: "MinioStorage",
max_memory_size: T.Optional[int] = None,
**kwargs,
):
@@ -118,8 +118,10 @@
self.max_memory_size = max_memory_size
super().__init__(name, mode, storage)
- def _get_file(self):
+ @property
+ def file(self):
if self._file is None:
+ obj = None
try:
obj = self._storage.client.get_object(
self._storage.bucket_name, self.name
@@ -135,16 +137,16 @@
raise minio_error(f"File {self.name} does not exist", error)
finally:
try:
- obj.release_conn()
+ if obj:
+ obj.release_conn()
except Exception as e:
logger.error(str(e))
return self._file
+ @file.setter
def _set_file(self, value):
self._file = value
- file = property(_get_file, _set_file)
-
def close(self):
if self._file is not None:
self._file.close()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/minio_storage/management/commands/minio.py
new/django-minio-storage-0.5.2/minio_storage/management/commands/minio.py
--- old/django-minio-storage-0.5.0/minio_storage/management/commands/minio.py
2023-04-23 13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/minio_storage/management/commands/minio.py
2023-05-06 06:01:34.000000000 +0200
@@ -1,6 +1,6 @@
-import argparse
import json
import sys
+import typing as T
from string import Template
from unittest.mock import patch
@@ -45,12 +45,8 @@
description="valid subcommands",
# required=True,
)
- cmds._parser_class = argparse.ArgumentParser # circumvent Django 1.11
bug
-
cmds.add_parser(self.CHECK, help="check bucket")
-
cmds.add_parser(self.CREATE, help="make bucket")
-
cmds.add_parser(self.DELETE, help="remove an empty bucket")
ls = cmds.add_parser(self.LIST, help="list bucket objects or buckets")
@@ -140,7 +136,7 @@
# TODO: maybe another way
with patch.object(storage_class, "_init_check", return_value=None):
- storage = storage_class()
+ storage = storage_class() # type: ignore
return storage
def bucket_exists(self, storage, bucket_name):
@@ -162,7 +158,7 @@
list_dirs: bool,
list_files: bool,
recursive: bool,
- format: str = None,
+ format: T.Optional[str] = None,
summary: bool = True,
):
try:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/minio_storage/policy.py
new/django-minio-storage-0.5.2/minio_storage/policy.py
--- old/django-minio-storage-0.5.0/minio_storage/policy.py 2023-04-23
13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/minio_storage/policy.py 2023-05-06
06:01:34.000000000 +0200
@@ -26,11 +26,11 @@
return pol
-def _none(bucket_name: str) -> T.Dict:
+def _none(bucket_name: str) -> T.Dict[str, T.Any]:
return {"Version": "2012-10-17", "Statement": []}
-def _get(bucket_name: str) -> T.Dict:
+def _get(bucket_name: str) -> T.Dict[str, T.Any]:
return {
"Version": "2012-10-17",
"Statement": [
@@ -44,7 +44,7 @@
}
-def _read(bucket_name: str) -> T.Dict:
+def _read(bucket_name: str) -> T.Dict[str, T.Any]:
return {
"Version": "2012-10-17",
"Statement": [
@@ -70,7 +70,7 @@
}
-def _write(bucket_name: str) -> T.Dict:
+def _write(bucket_name: str) -> T.Dict[str, T.Any]:
return {
"Version": "2012-10-17",
"Statement": [
@@ -101,7 +101,7 @@
}
-def _read_write(bucket_name: str) -> T.Dict:
+def _read_write(bucket_name: str) -> T.Dict[str, T.Any]:
return {
"Version": "2012-10-17",
"Statement": [
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/minio_storage/storage.py
new/django-minio-storage-0.5.2/minio_storage/storage.py
--- old/django-minio-storage-0.5.0/minio_storage/storage.py 2023-04-23
13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/minio_storage/storage.py 2023-05-06
06:01:34.000000000 +0200
@@ -2,9 +2,8 @@
import mimetypes
import posixpath
import typing as T
-import urllib
from logging import getLogger
-from urllib.parse import urlsplit, urlunsplit
+from urllib.parse import quote, urlsplit, urlunsplit
import minio
import minio.error as merr
@@ -13,6 +12,7 @@
from django.core.files.storage import Storage
from django.utils import timezone
from django.utils.deconstruct import deconstructible
+from minio.datatypes import Object
from minio_storage.errors import minio_error
from minio_storage.files import ReadOnlySpooledTemporaryFile
@@ -107,22 +107,15 @@
base_url_parts = urlsplit(base_url)
# Clone from the normal client, but with base_url as the endpoint
- credentials = client._provider.retrieve()
base_url_client = minio.Minio(
base_url_parts.netloc,
- access_key=credentials.access_key,
- secret_key=credentials.secret_key,
- session_token=credentials.session_token,
+ credentials=client._provider,
secure=base_url_parts.scheme == "https",
# The bucket region may be auto-detected by client (via an HTTP
# request), so don't just use client._region
region=client._get_region(bucket_name, None),
http_client=client._http,
)
- if hasattr(client, "_credentials"):
- # Client credentials do not exist prior to minio-py 5.0.7, but
- # they should be reused if possible
- base_url_client._credentials = client._credentials
return base_url_client
@@ -154,7 +147,7 @@
raise minio_error(f"File {name} could not be saved: {str(e)}", e)
return f
- def _save(self, name: str, content: bytes) -> str:
+ def _save(self, name: str, content: T.BinaryIO) -> str:
try:
if hasattr(content, "seek") and callable(content.seek):
content.seek(0)
@@ -212,16 +205,15 @@
return True
except merr.InvalidResponseError as error:
# TODO - deprecate
- if error.code == "NoSuchKey":
+ if error._code == "NoSuchKey":
return False
else:
raise minio_error(f"Could not stat file {name}", error)
except merr.S3Error:
return False
- except merr.S3Error:
- raise
except Exception as error:
logger.error(error)
+ return False
def listdir(self, path: str) -> T.Tuple[T.List, T.List]:
# [None, "", "."] is supported to mean the configured root among
various
@@ -256,14 +248,14 @@
def size(self, name: str) -> int:
try:
- info = self.client.stat_object(self.bucket_name, name)
- return info.size
+ info: Object = self.client.stat_object(self.bucket_name, name)
+ return info.size # type: ignore
except merr.InvalidResponseError as error:
raise minio_error(f"Could not access file size for {name}", error)
def _presigned_url(
self, name: str, max_age: T.Optional[datetime.timedelta] = None
- ) -> str:
+ ) -> T.Optional[str]:
kwargs = {}
if max_age is not None:
kwargs["expires"] = max_age
@@ -293,11 +285,14 @@
url_parts.fragment,
)
)
- return url
+ if url:
+ return str(url)
+ return None
def url(
self, name: str, *args, max_age: T.Optional[datetime.timedelta] = None
) -> str:
+ url = ""
if self.presign_urls:
url = self._presigned_url(name, max_age=max_age)
else:
@@ -313,16 +308,16 @@
return path
if self.base_url is not None:
- url = "{}/{}".format(
- strip_end(self.base_url),
urllib.parse.quote(strip_beg(name))
- )
+ url = "{}/{}".format(strip_end(self.base_url),
quote(strip_beg(name)))
else:
url = "{}/{}/{}".format(
strip_end(self.endpoint_url),
self.bucket_name,
- urllib.parse.quote(strip_beg(name)),
+ quote(strip_beg(name)),
)
- return url
+ if url:
+ return url
+ raise OSError(f"could not produce URL for {name}")
@property
def endpoint_url(self):
@@ -342,18 +337,20 @@
def modified_time(self, name: str) -> datetime.datetime:
try:
- info = self.client.stat_object(self.bucket_name, name)
- return info.last_modified
+ info: Object = self.client.stat_object(self.bucket_name, name)
+ if info.last_modified:
+ return info.last_modified # type: ignore
except merr.InvalidResponseError as error:
raise minio_error(
f"Could not access modification time for file {name}", error
)
+ raise OSError(f"Could not access modification time for file {name}")
_NoValue = object()
-def get_setting(name, default=_NoValue):
+def get_setting(name: str, default=_NoValue) -> T.Any:
result = getattr(settings, name, default)
if result is _NoValue:
# print("Attr {} : {}".format(name, getattr(settings, name, default)))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/minio_storage/version.py
new/django-minio-storage-0.5.2/minio_storage/version.py
--- old/django-minio-storage-0.5.0/minio_storage/version.py 2023-04-23
13:01:30.000000000 +0200
+++ new/django-minio-storage-0.5.2/minio_storage/version.py 2023-05-06
06:01:56.000000000 +0200
@@ -1 +1 @@
-__version__ = "0.5.0"
+__version__ = "0.5.2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/pyrightconfig.json
new/django-minio-storage-0.5.2/pyrightconfig.json
--- old/django-minio-storage-0.5.0/pyrightconfig.json 1970-01-01
01:00:00.000000000 +0100
+++ new/django-minio-storage-0.5.2/pyrightconfig.json 2023-05-06
06:01:34.000000000 +0200
@@ -0,0 +1,18 @@
+{
+ "include": [
+ "minio_storage",
+ "tests"
+ ],
+ "exclude": [
+ "**/migrations"
+ ],
+ "reportMissingImports": true,
+ "reportMissingTypeStubs": false,
+ "strictParameterNoneValue": true,
+ "reportInvalidStringEscapeSequence": "error",
+ "reportUnboundVariable": "error",
+ "reportOptionalMemberAccess": "error",
+ "reportOptionalIterable": "error",
+ "pythonVersion": "3.8",
+ "pythonPlatform": "Linux"
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/tests/test_app/tests/bucket_tests.py
new/django-minio-storage-0.5.2/tests/test_app/tests/bucket_tests.py
--- old/django-minio-storage-0.5.0/tests/test_app/tests/bucket_tests.py
2023-04-23 13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/tests/test_app/tests/bucket_tests.py
2023-05-06 06:01:34.000000000 +0200
@@ -29,7 +29,7 @@
with self.assertRaises(OSError):
MinioStaticStorage()
- def test_get_setting_throws_early(self):
+ def test_get_setting_raises_exception(self):
with self.assertRaises(ImproperlyConfigured):
get_setting("INEXISTENT_SETTING")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/tests/test_app/tests/custom_storage_class_tests.py
new/django-minio-storage-0.5.2/tests/test_app/tests/custom_storage_class_tests.py
---
old/django-minio-storage-0.5.0/tests/test_app/tests/custom_storage_class_tests.py
2023-04-23 13:01:14.000000000 +0200
+++
new/django-minio-storage-0.5.2/tests/test_app/tests/custom_storage_class_tests.py
2023-05-06 06:01:34.000000000 +0200
@@ -19,18 +19,18 @@
@deconstructible
-class SecretStorage(MinioStorage):
- """The SecretStorage MinioStorage subclass can be used directly, as a
storage in
+class PrivateStorage(MinioStorage):
+ """The PrivateStorage MinioStorage subclass can be used directly, as a
storage in
settings.DEFAULT_FILE_STORAGE or after instantiated used individually on
any django
FileField:
from django.db import models
- ss = SecretStorage(bucket_name='invoices')
+ private_storage = PrivateStorage(bucket_name='invoices')
class Invoice(models.Model):
...
- pdf = models.FileField(storage=ss)
+ pdf = models.FileField(storage=private_storage)
"""
@@ -51,7 +51,7 @@
# or use our own Django setting
#
if bucket_name is None:
- bucket_name = get_setting("SECRET_BUCKET_NAME")
+ bucket_name = get_setting("PRIVATE_BUCKET_NAME")
# Run the super constructor and make a choice to only use presigned
urls with
# this bucket so that we can keep files more private here than how
media files
@@ -67,12 +67,12 @@
class CustomStorageTests(BaseTestMixin, TestCase):
-
@override_settings(SECRET_BUCKET_NAME=create_test_bucket_name("my-secret-bucket"))
+
@override_settings(PRIVATE_BUCKET_NAME=create_test_bucket_name("my-private-bucket"))
def test_custom_storage(self):
# Instansiate a storage class and put a file in it so that we have
something to
# work with.
#
- storage = SecretStorage()
+ storage = PrivateStorage()
storage_filename = storage.save("secret.txt", ContentFile(b"abcd"))
# Create a temporary workspace directory.
@@ -96,14 +96,15 @@
) as storage_file:
# Copy the stream from the http stream to the out_file
#
- shutil.copyfileobj(storage_file.file, out_file)
+ shutil.copyfileobj(storage_file.file, out_file) # type: ignore
#
# We are not using the ReadOnlyMinioObjectFile type so we
can't seek in
# it.
#
with self.assertRaises(io.UnsupportedOperation):
- storage_file.file.seek()
+ if storage_file.file:
+ storage_file.file.seek(0)
workspace_files = os.listdir(workspace)
print(workspace_files) # prints: ['secret.txt']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/tests/test_app/tests/retrieve_tests.py
new/django-minio-storage-0.5.2/tests/test_app/tests/retrieve_tests.py
--- old/django-minio-storage-0.5.0/tests/test_app/tests/retrieve_tests.py
2023-04-23 13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/tests/test_app/tests/retrieve_tests.py
2023-05-06 06:01:34.000000000 +0200
@@ -1,7 +1,6 @@
import datetime
import io
import os
-import unittest
import requests
from django.core.files.base import ContentFile
@@ -9,7 +8,6 @@
from freezegun import freeze_time
from minio.error import S3Error
-from minio_storage.errors import MinIOError
from minio_storage.storage import MinioMediaStorage
from .utils import BaseTestMixin
@@ -41,7 +39,7 @@
test_file = self.media_storage.save("sizetest.txt",
ContentFile(b"1234"))
self.assertEqual(4, self.media_storage.size(test_file))
- def test_size_of_non_existent_throws(self):
+ def test_size_of_non_existent_raises_exception(self):
test_file = self.media_storage.save("sizetest.txt",
ContentFile(b"1234"))
self.media_storage.delete(test_file)
with self.assertRaises(S3Error):
@@ -62,7 +60,7 @@
self.media_storage.created_time(self.new_file), datetime.datetime
)
- def test_modified_time_of_non_existent_throws(self):
+ def test_modified_time_of_non_existent_raises_exception(self):
with self.assertRaises(S3Error):
self.media_storage.modified_time("nonexistent.jpg")
@@ -116,19 +114,10 @@
def test_file_exists_failure(self):
self.assertFalse(self.media_storage.exists("nonexistent.txt"))
- @unittest.skip("Skipping this test because undecided if it should raise
exception")
- def test_opening_non_existing_file_raises_oserror(self):
- with self.assertRaises(OSError):
- self.media_storage.open("this does not exist")
-
- @unittest.skip("Skipping this test because undecided if it should raise
exception")
- def test_opening_non_existing_file_raises_minioerror(self):
- with self.assertRaises(MinIOError):
- self.media_storage.open("this does not exist")
- try:
- self.media_storage.open("this does not exist")
- except MinIOError as e:
- assert e.cause.__class__ == S3Error
+ def test_reading_non_existing_file_raises_exception(self):
+ with self.assertRaises(Exception):
+ f = self.media_storage.open("this does not exist")
+ f.read()
def test_file_names_are_properly_sanitized(self):
self.media_storage.save("./meh22222.txt", io.BytesIO(b"stuff"))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/django-minio-storage-0.5.0/tests/test_app/tests/upload_tests.py
new/django-minio-storage-0.5.2/tests/test_app/tests/upload_tests.py
--- old/django-minio-storage-0.5.0/tests/test_app/tests/upload_tests.py
2023-04-23 13:01:14.000000000 +0200
+++ new/django-minio-storage-0.5.2/tests/test_app/tests/upload_tests.py
2023-05-06 06:01:34.000000000 +0200
@@ -66,15 +66,6 @@
def test_upload_and_get_back_file_with_funky_name(self):
self.media_storage.save("áÄÄÄÅ¡ÄÅžýŽÅůúť.txt",
ContentFile(b"12345"))
- def test_uploaded_and_downloaded_file_sizes_match(self):
- pass
-
- def test_uploaded_files_end_up_in_the_right_bucket(self):
- pass
-
- def test_static_files_end_up_in_the_right_bucket(self):
- pass
-
def test_upload_file_beggining_with_dot(self):
self.media_storage.save(
".hidden_file", ContentFile(b"Not really, but whatever")
@@ -101,7 +92,7 @@
"X-Xss-Protection",
"Date",
}
- self.assertTrue(metadata_attrs.issubset(res.metadata.keys()))
+ self.assertTrue(metadata_attrs.issubset(res.metadata.keys())) # type:
ignore
@override_settings(
@@ -114,4 +105,4 @@
self.media_storage.bucket_name, ivan
)
- self.assertEqual(res.metadata["Cache-Control"], "max-age=1000")
+ self.assertEqual(res.metadata["Cache-Control"], "max-age=1000") #
type: ignore
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/django-minio-storage-0.5.0/tox.ini
new/django-minio-storage-0.5.2/tox.ini
--- old/django-minio-storage-0.5.0/tox.ini 2023-04-23 13:01:14.000000000
+0200
+++ new/django-minio-storage-0.5.2/tox.ini 2023-05-06 06:01:34.000000000
+0200
@@ -1,17 +1,25 @@
-[pytest]
-pythonpath = . tests
-DJANGO_SETTINGS_MODULE = django_minio_storage_tests.settings
-addopts=--tb=short
-python_files = tests.py test_*.py *_tests.py
-django_find_project = false
+[tox]
+envlist =
+ {py38,py39,py310,py311}-django42-minioknown
+ py311-django{32,42}-minioknown
+ py311-django42-minio
+ lint
+ docs
+ pyright
[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
- 3.11: py311, lint, docs
+ 3.11: py311, lint, docs, pyright
+[pytest]
+pythonpath = . tests
+DJANGO_SETTINGS_MODULE = django_minio_storage_tests.settings
+addopts=--tb=short
+python_files = tests.py test_*.py *_tests.py
+django_find_project = false
[testenv]
commands = pytest {posargs}
@@ -28,6 +36,28 @@
minioknown: minio==7.1.12
-rdev-requirements.txt
+[testenv:py311-django42-minioknown]
+commands = pytest --cov --cov-append --cov-report=term-missing {posargs}
+
+[testenv:coverage-report]
+basepython = python3.11
+deps = coverage[toml]
+skip_install = true
+commands =
+ coverage report
+ coverage html
+depends=py311-django42-minioknown
+
+[testenv:pyright]
+basepython = python3
+deps =
+ pyright
+ django-stubs==4.2.0
+ -rdev-requirements.txt
+commands =
+ pyright --level WARNING
+
+
[testenv:lint]
setenv=
PYTHONWARNINGS=ignore
@@ -60,10 +90,3 @@
deps = mkdocs
commands = mkdocs build
-[tox]
-envlist =
- {py38,py39,py310,py311}-django42-minioknown
- py311-django{32,42}-minioknown
- py311-django42-minio
- lint
- docs