Skip to content

Commit

Permalink
Improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Oct 22, 2024
1 parent 6292bfc commit 785305a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
7 changes: 2 additions & 5 deletions audbackend/core/backend/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,8 @@ def _owner(
# NOTE:
# we use a custom metadata entry to track the owner
# as stats.owner_name is always empty.
owner = ""
stats = self._client.stat_object(self.repository, path)
if "x-amz-meta-owner" in stats.metadata:
owner = stats.metadata["x-amz-meta-owner"]
return owner
meta = self._client.stat_object(self.repository, path).metadata
return meta["x-amz-meta-owner"] if "x-amz-meta-owner" in meta else ""

def path(
self,
Expand Down
25 changes: 12 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@
def authentication():
"""Provide authentication tokens for supported backends."""
if pytest.HOSTS["minio"] == "play.min.io":
defaults = {}
for key in [
"MINIO_ACCESS_KEY",
"MINIO_SECRET_KEY",
]:
defaults[key] = os.environ.get(key, None)

defaults = {
key: os.environ.get(key, None)
for key in ["MINIO_ACCESS_KEY", "MINIO_SECRET_KEY"]
}
# MinIO credentials for the public read/write server
# at play.min.io, see
# https://min.io/docs/minio/linux/developers/python/minio-py.html
os.environ["MINIO_ACCESS_KEY"] = "Q3AM3UQ867SPQQA43P2F"
os.environ["MINIO_SECRET_KEY"] = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
else:
defaults = {}

yield
yield

for key, value in defaults.items():
if value is not None:
os.environ[key] = value
elif key in os.environ:
del os.environ[key]
for key, value in defaults.items():
if value is not None:
os.environ[key] = value
elif key in os.environ:
del os.environ[key]


@pytest.fixture(scope="package", autouse=True)
Expand Down

0 comments on commit 785305a

Please sign in to comment.