Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions minio/commonconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ def build_headers(self, object_size: int, etag: str):
@property
def object_size(self) -> Optional[int]:
"""Get object size."""
if self.object_size is None:
if self._object_size is None:
raise MinioException(
"build_headers() must be called prior to "
"this method invocation",
)
return self.object_size
return self._object_size

@property
def headers(self) -> dict[str, str]:
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/composesource_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage,
# (C) 2015, 2016 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import TestCase

from minio.commonconfig import ComposeSource
from minio.error import MinioException


class ComposeSourceTest(TestCase):
def test_object_size(self):
source = ComposeSource(bucket_name="my-bucket",
object_name="my-object")
with self.assertRaises(MinioException) as exc:
_ = source.object_size

msg = "build_headers() must be called prior to this method invocation"
self.assertEqual(msg, str(exc.exception))
Loading