From a315cdaf7c2a70750beb9083d87d84b676f69dff Mon Sep 17 00:00:00 2001 From: pjsier Date: Sun, 12 Sep 2021 19:32:14 -0500 Subject: [PATCH] remove extra azure filepath_to_uri call --- storages/backends/azure_storage.py | 5 ++--- tests/test_azure.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/storages/backends/azure_storage.py b/storages/backends/azure_storage.py index f2401ebe9..0fa78dcb7 100644 --- a/storages/backends/azure_storage.py +++ b/storages/backends/azure_storage.py @@ -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 ( @@ -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): diff --git a/tests/test_azure.py b/tests/test_azure.py index fe69431d9..4baa1d5a5 100644 --- a/tests/test_azure.py +++ b/tests/test_azure.py @@ -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() @@ -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):