Skip to content

Rename time information APIs to be Django-compliant #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions minio_storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,19 @@ def strip_end(path):
def endpoint_url(self):
return self.client._base_url._url.geturl()

def accessed_time(self, name: str) -> datetime.datetime:
def get_accessed_time(self, name: str) -> T.NoReturn:
"""
Not available via the S3 API
"""
return self.modified_time(name)
raise NotImplementedError("Accessed time is not supported")

def created_time(self, name: str) -> datetime.datetime:
def get_created_time(self, name: str) -> T.NoReturn:
"""
Not available via the S3 API
"""
return self.modified_time(name)
raise NotImplementedError("Created time is not supported")

def modified_time(self, name: str) -> datetime.datetime:
def get_modified_time(self, name: str) -> datetime.datetime:
try:
info: Object = self.client.stat_object(self.bucket_name, name)
except merr.InvalidResponseError as error:
Expand Down
20 changes: 9 additions & 11 deletions tests/test_app/tests/retrieve_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,22 @@ def test_size_of_non_existent_raises_exception(self):
with self.assertRaises(S3Error):
self.media_storage.size(test_file)

def test_modified_time(self):
def test_get_modified_time(self):
self.assertIsInstance(
self.media_storage.modified_time(self.new_file), datetime.datetime
self.media_storage.get_modified_time(self.new_file), datetime.datetime
)

def test_accessed_time(self):
self.assertIsInstance(
self.media_storage.accessed_time(self.new_file), datetime.datetime
)
def test_get_accessed_time(self):
with self.assertRaises(NotImplementedError):
self.media_storage.get_accessed_time(self.new_file)

def test_created_time(self):
self.assertIsInstance(
self.media_storage.created_time(self.new_file), datetime.datetime
)
def test_get_created_time(self):
with self.assertRaises(NotImplementedError):
self.media_storage.get_created_time(self.new_file)

def test_modified_time_of_non_existent_raises_exception(self):
with self.assertRaises(S3Error):
self.media_storage.modified_time("nonexistent.jpg")
self.media_storage.get_modified_time("nonexistent.jpg")

def _listdir_root(self, root):
self.media_storage.save("dir1/file2.txt", ContentFile(b"meh"))
Expand Down