Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions sdk/storage/azure-storage-blob/azure/storage/blob/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class BlobProperties(DictMixin):
The container in which the blob resides.
:ivar str snapshot:
Datetime value that uniquely identifies the blob snapshot.
:ivar ~azure.blob.storage.models.BlobType blob_type:
:ivar ~azure.blob.storage.BlobType blob_type:
String indicating this blob's type.
:ivar dict metadata:
Name-value pairs associated with the blob as metadata.
Expand Down Expand Up @@ -629,9 +629,9 @@ class LeaseProperties(DictMixin):
"""

def __init__(self, **kwargs):
self.status = kwargs.get('x-ms-lease-status')
self.state = kwargs.get('x-ms-lease-state')
self.duration = kwargs.get('x-ms-lease-duration')
self.status = get_enum_value(kwargs.get('x-ms-lease-status'))
self.state = get_enum_value(kwargs.get('x-ms-lease-state'))
self.duration = get_enum_value(kwargs.get('x-ms-lease-duration'))

@classmethod
def _from_generated(cls, generated):
Expand Down Expand Up @@ -740,7 +740,7 @@ class CopyProperties(DictMixin):
def __init__(self, **kwargs):
self.id = kwargs.get('x-ms-copy-id')
self.source = kwargs.get('x-ms-copy-source')
self.status = kwargs.get('x-ms-copy-status')
self.status = get_enum_value(kwargs.get('x-ms-copy-status'))
self.progress = kwargs.get('x-ms-copy-progress')
self.completion_time = kwargs.get('x-ms-copy-completion_time')
self.status_description = kwargs.get('x-ms-copy-status-description')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DecodeError)

from .parser import _to_utc_datetime
from .models import StorageErrorCode, UserDelegationKey
from .models import StorageErrorCode, UserDelegationKey, get_enum_value


if TYPE_CHECKING:
Expand Down Expand Up @@ -62,7 +62,7 @@ def normalize_headers(headers):
for key, value in headers.items():
if key.startswith('x-ms-'):
key = key[5:]
normalized[key.lower().replace('-', '_')] = value
normalized[key.lower().replace('-', '_')] = get_enum_value(value)
return normalized


Expand Down
8 changes: 5 additions & 3 deletions sdk/storage/azure-storage-blob/tests/test_common_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from enum import Enum
import pytest
import requests
import time
Expand Down Expand Up @@ -860,6 +861,7 @@ def test_copy_blob_with_existing_blob(self):
# Assert
self.assertIsNotNone(copy)
self.assertEqual(copy['copy_status'], 'success')
self.assertFalse(isinstance(copy['copy_status'], Enum))
self.assertIsNotNone(copy['copy_id'])

copy_content = copyblob.download_blob().readall()
Expand Down Expand Up @@ -1108,7 +1110,7 @@ def test_lease_blob_acquire_and_renew(self):
lease = blob.acquire_lease()
first_id = lease.id
lease.renew()

# Assert
self.assertEqual(first_id, lease.id)

Expand Down Expand Up @@ -1213,7 +1215,7 @@ def test_sas_access_blob(self):
# Arrange
blob_name = self._create_block_blob()
blob = self.bsc.get_blob_client(self.container_name, blob_name)

token = generate_blob_sas(
blob.account_name,
blob.container_name,
Expand Down Expand Up @@ -1903,7 +1905,7 @@ def test_set_blob_permission(self):
self.assertEqual(permission.delete, True)
self.assertEqual(permission.write, True)
self.assertEqual(permission._str, 'wrdx')

def test_transport_closed_only_once(self):
if TestMode.need_recording_file(self.test_mode):
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from enum import Enum
import pytest
import asyncio
import requests
Expand Down Expand Up @@ -1142,6 +1143,7 @@ async def _test_copy_blob_with_existing_blob(self):
# Assert
self.assertIsNotNone(copy)
self.assertEqual(copy['copy_status'], 'success')
self.assertFalse(isinstance(copy['copy_status'], Enum))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to assert it is a string more than just not enum. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the first thing I did, but the original is a string AND an enum (multiple inheritance). So both test were True :)
Being that the line before is testing the string, I think we're good :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiangyan99 - that's already implied by the assertEqual statement above?

self.assertIsNotNone(copy['copy_id'])

copy_content = await (await copyblob.download_blob()).readall()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class CopyProperties(DictMixin):
def __init__(self, **kwargs):
self.id = kwargs.get('x-ms-copy-id')
self.source = kwargs.get('x-ms-copy-source')
self.status = kwargs.get('x-ms-copy-status')
self.status = get_enum_value(kwargs.get('x-ms-copy-status'))
self.progress = kwargs.get('x-ms-copy-progress')
self.completion_time = kwargs.get('x-ms-copy-completion_time')
self.status_description = kwargs.get('x-ms-copy-status-description')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DecodeError)

from .parser import _to_utc_datetime
from .models import StorageErrorCode, UserDelegationKey
from .models import StorageErrorCode, UserDelegationKey, get_enum_value


if TYPE_CHECKING:
Expand Down Expand Up @@ -62,7 +62,7 @@ def normalize_headers(headers):
for key, value in headers.items():
if key.startswith('x-ms-'):
key = key[5:]
normalized[key.lower().replace('-', '_')] = value
normalized[key.lower().replace('-', '_')] = get_enum_value(value)
return normalized


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
DecodeError)

from .parser import _to_utc_datetime
from .models import StorageErrorCode, UserDelegationKey
from .models import StorageErrorCode, UserDelegationKey, get_enum_value


if TYPE_CHECKING:
Expand Down Expand Up @@ -62,7 +62,7 @@ def normalize_headers(headers):
for key, value in headers.items():
if key.startswith('x-ms-'):
key = key[5:]
normalized[key.lower().replace('-', '_')] = value
normalized[key.lower().replace('-', '_')] = get_enum_value(value)
return normalized


Expand Down