Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
comment changes
  • Loading branch information
rakshith91 committed Oct 3, 2019
commit 87103ada0bbee590170c1ee792e1ddeb7efb53d7
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ def from_blob_url(cls, blob_url, credential=None, snapshot=None, **kwargs):
raise ValueError("Invalid URL: {}".format(blob_url))
account_url = parsed_url.netloc.rstrip('/') + "?" + parsed_url.query
container_name, _, blob_name = parsed_url.path.lstrip('/').partition('/')
if not container_name or not blob_name:
raise ValueError("Invalid URL. Provide a blob_url with a valid blob and container name.")

path_snapshot, sas_token = parse_query(parsed_url.query)
if snapshot is not None:
path_snapshot, _ = parse_query(parsed_url.query)
if snapshot:
try:
path_snapshot = snapshot.snapshot # type: ignore
except AttributeError:
Expand Down
10 changes: 10 additions & 0 deletions sdk/storage/azure-storage-blob/tests/test_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ def test_create_service_with_key(self):
self.validate_standard_account_endpoints(service, url)
self.assertEqual(service.scheme, 'https')

def test_create_blob_client_with_complete_blob_url(self):
# Arrange
blob_url = self._get_account_url() + "/foourl/barurl"
service = BlobClient(blob_url, credential=self.account_key, container_name='foo', blob_name='bar')

# Assert
self.assertEqual(service.scheme, 'https')
self.assertEqual(service.container_name, 'foo')
self.assertEqual(service.blob_name, 'bar')

def test_create_service_with_connection_string(self):

for service_type in SERVICES.items():
Expand Down
10 changes: 10 additions & 0 deletions sdk/storage/azure-storage-blob/tests/test_blob_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ def test_create_service_with_connection_string_sas_async(self):
self.assertTrue(service.url.endswith(self.sas_token))
self.assertIsNone(service.credential)

def test_create_blob_client_with_complete_blob_url_async(self):
# Arrange
blob_url = self._get_account_url() + "/foourl/barurl"
service = BlobClient(blob_url, credential=self.account_key, container_name='foo', blob_name='bar')

# Assert
self.assertEqual(service.scheme, 'https')
self.assertEqual(service.container_name, 'foo')
self.assertEqual(service.blob_name, 'bar')

def test_create_service_with_connection_string_endpoint_protocol_async(self):
# Arrange
conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format(
Expand Down