Skip to content

Commit

Permalink
[Blob]fix parse url for blob emulator (#15979)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiafu-msft authored Jan 11, 2021
1 parent efb8e39 commit e9d2636
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def from_blob_url(cls, blob_url, credential=None, snapshot=None, **kwargs):
path_blob = parsed_url.path.lstrip('/').split('/', 1)
elif "localhost" in parsed_url.netloc or "127.0.0.1" in parsed_url.netloc:
path_blob = parsed_url.path.lstrip('/').split('/', 2)
account_path += path_blob[0]
account_path += '/' + path_blob[0]
else:
# for customized url. blob name that has directory info cannot be parsed.
path_blob = parsed_url.path.lstrip('/').split('/')
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-blob/tests/test_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ def test_create_blob_client_with_sub_directory_path_in_blob_name(self):
blob_client = BlobClient.from_blob_url(blob_emulator_url)
self.assertEqual(blob_client.container_name, "containername")
self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg")
self.assertEqual(blob_client.url, blob_emulator_url)

def test_create_client_for_emulator(self):
container_client = ContainerClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ def test_create_blob_client_with_sub_directory_path_in_blob_name(self):
blob_client = BlobClient.from_blob_url(blob_emulator_url)
self.assertEqual(blob_client.container_name, "containername")
self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg")
self.assertEqual(blob_client.url, blob_emulator_url)

@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
Expand Down

0 comments on commit e9d2636

Please sign in to comment.