Skip to content

Commit

Permalink
remove extra azure filepath_to_uri call
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsier committed Sep 19, 2021
1 parent 6c5ea2a commit 56302e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions storages/backends/azure_storage.py
Expand Up @@ -11,7 +11,7 @@
from django.core.files.base import File
from django.utils import timezone
from django.utils.deconstruct import deconstructible
from django.utils.encoding import filepath_to_uri, force_bytes
from django.utils.encoding import force_bytes

from storages.base import BaseStorage
from storages.utils import (
Expand Down Expand Up @@ -271,8 +271,7 @@ def url(self, name, expire=None):
expiry=self._expire_at(expire))
credential = sas_token

container_blob_url = self.client.get_blob_client(
filepath_to_uri(name)).url
container_blob_url = self.client.get_blob_client(name).url
return BlobClient.from_blob_url(container_blob_url, credential=credential).url

def _get_content_settings_parameters(self, name, content=None):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_azure.py
Expand Up @@ -142,7 +142,7 @@ def test_url(self):
blob_mock.url = 'https://ret_foo.blob.core.windows.net/test/some%20blob'
self.storage._client.get_blob_client.return_value = blob_mock
self.assertEqual(self.storage.url('some blob'), blob_mock.url)
self.storage._client.get_blob_client.assert_called_once_with('some%20blob')
self.storage._client.get_blob_client.assert_called_once_with('some blob')

def test_url_unsafe_chars(self):
blob_mock = mock.MagicMock()
Expand All @@ -151,7 +151,7 @@ def test_url_unsafe_chars(self):
self.assertEqual(
self.storage.url('foo;?:@=&"<>#%{}|^~[]`bar/~!*()\''), blob_mock.url)
self.storage.client.get_blob_client.assert_called_once_with(
'foo%3B%3F%3A%40%3D%26%22%3C%3E%23%25%7B%7D%7C%5E~%5B%5D%60bar/~!*()\'')
'foo;?:@=&"<>#%{}|^~[]`bar/~!*()\'')

@mock.patch('storages.backends.azure_storage.generate_blob_sas')
def test_url_expire(self, generate_blob_sas_mocked):
Expand Down

0 comments on commit 56302e5

Please sign in to comment.