Skip to content

Commit

Permalink
[azure] fix get_modified_time() (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed May 19, 2022
1 parent f607b54 commit 5015c24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions storages/backends/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ def get_modified_time(self, name):
Returns an (aware) datetime object containing the last modified time if
USE_TZ is True, otherwise returns a naive datetime in the local timezone.
"""
properties = self.client.get_blob_properties(
self._get_valid_path(name),
timeout=self.timeout)
blob_client = self.client.get_blob_client(self._get_valid_path(name))
properties = blob_client.get_blob_properties(timeout=self.timeout)
if not setting('USE_TZ', False):
return timezone.make_naive(properties.last_modified)

Expand Down
4 changes: 3 additions & 1 deletion tests/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ def test_last_modified_of_file(self):
props = BlobProperties()
accepted_time = datetime.datetime(2017, 5, 11, 8, 52, 4)
props.last_modified = accepted_time
self.storage._client.get_blob_properties.return_value = props
client_mock = mock.MagicMock()
client_mock.get_blob_properties.return_value = props
self.storage._client.get_blob_client.return_value = client_mock
time = self.storage.modified_time("name")
self.assertEqual(accepted_time, time)

Expand Down

0 comments on commit 5015c24

Please sign in to comment.