Skip to content

Commit

Permalink
Added async tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zezha-msft committed Jun 4, 2020
1 parent 0df8808 commit 8ef4eab
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ def deserialize_ors_policies(response):

parsed_result = {}

# all the ors headers have the same prefix, so we note down its length here to avoid recalculating it repeatedly
header_prefix_length = len('x-ms-or-')

for key, val in or_policy_status_headers.items():
policy_and_rule_ids = key[len('x-ms-or-'):].split('_')
policy_and_rule_ids = key[header_prefix_length:].split('_')
policy_id = policy_and_rule_ids[0]
rule_id = policy_and_rule_ids[1]

# we are seeing this policy for the first time, so a new rule_id -> result dict is needed
if parsed_result.get(policy_id) is None:
try:
parsed_result[policy_id][rule_id] = val
except KeyError:
# we are seeing this policy for the first time, so a new rule_id -> result dict is needed
parsed_result[policy_id] = {rule_id: val}
else:
parsed_result.get(policy_id)[rule_id] = val

return parsed_result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class BlobProperties(DictMixin):
Whether this blob is encrypted.
:ivar dict(str, dict(str, str)) object_replication_source_properties:
Only present for blobs that have policy ids and rule ids applied to them.
Dictionary<policy_id, Dictionary<rule_id, status of replication(Complete,Failed)
Dictionary<policy_id, Dictionary<rule_id, status of replication(complete,failed)>
:ivar str object_replication_destination_policy:
Represents the Object Replication Policy Id that created this blob.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:39:03 GMT
- Thu, 04 Jun 2020 07:20:14 GMT
x-ms-version:
- '2019-12-12'
method: HEAD
Expand All @@ -31,7 +31,7 @@ interactions:
content-type:
- application/octet-stream
date:
- Tue, 19 May 2020 09:39:03 GMT
- Thu, 04 Jun 2020 07:20:14 GMT
etag:
- '"0x8D7FB118A463E24"'
last-modified:
Expand Down Expand Up @@ -81,7 +81,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:39:04 GMT
- Thu, 04 Jun 2020 07:20:34 GMT
x-ms-range:
- bytes=0-33554431
x-ms-version:
Expand All @@ -91,8 +91,8 @@ interactions:
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>InvalidRange</Code><Message>The\
\ range specified is invalid for the current size of the resource.\nRequestId:1986b217-b01e-001e-0fc1-2d361a000000\n\
Time:2020-05-19T09:39:04.3407618Z</Message></Error>"
\ range specified is invalid for the current size of the resource.\nRequestId:83ee5103-101e-004a-7540-3a794d000000\n\
Time:2020-06-04T07:20:35.0604924Z</Message></Error>"
headers:
content-length:
- '249'
Expand All @@ -101,7 +101,7 @@ interactions:
content-type:
- application/xml
date:
- Tue, 19 May 2020 09:39:03 GMT
- Thu, 04 Jun 2020 07:20:34 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code:
Expand All @@ -123,7 +123,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:39:04 GMT
- Thu, 04 Jun 2020 07:20:35 GMT
x-ms-version:
- '2019-12-12'
method: GET
Expand All @@ -143,7 +143,7 @@ interactions:
content-type:
- application/octet-stream
date:
- Tue, 19 May 2020 09:39:03 GMT
- Thu, 04 Jun 2020 07:20:34 GMT
etag:
- '"0x8D7FB118A463E24"'
last-modified:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:27:35 GMT
- Thu, 04 Jun 2020 07:21:55 GMT
x-ms-version:
- '2019-12-12'
method: HEAD
Expand All @@ -31,7 +31,7 @@ interactions:
content-type:
- application/octet-stream
date:
- Tue, 19 May 2020 09:27:34 GMT
- Thu, 04 Jun 2020 07:21:55 GMT
etag:
- '"0x8D7FB114288CFC9"'
last-modified:
Expand Down Expand Up @@ -75,7 +75,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:27:35 GMT
- Thu, 04 Jun 2020 07:22:14 GMT
x-ms-range:
- bytes=0-33554431
x-ms-version:
Expand All @@ -85,8 +85,8 @@ interactions:
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>InvalidRange</Code><Message>The\
\ range specified is invalid for the current size of the resource.\nRequestId:af9e849b-401e-0065-20bf-2de3e4000000\n\
Time:2020-05-19T09:27:35.8264761Z</Message></Error>"
\ range specified is invalid for the current size of the resource.\nRequestId:9c802dbf-401e-004a-1640-3aee2f000000\n\
Time:2020-06-04T07:22:14.3763358Z</Message></Error>"
headers:
content-length:
- '249'
Expand All @@ -95,7 +95,7 @@ interactions:
content-type:
- application/xml
date:
- Tue, 19 May 2020 09:27:35 GMT
- Thu, 04 Jun 2020 07:22:13 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code:
Expand All @@ -117,7 +117,7 @@ interactions:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Tue, 19 May 2020 09:27:35 GMT
- Thu, 04 Jun 2020 07:22:14 GMT
x-ms-version:
- '2019-12-12'
method: GET
Expand All @@ -137,7 +137,7 @@ interactions:
content-type:
- application/octet-stream
date:
- Tue, 19 May 2020 09:27:35 GMT
- Thu, 04 Jun 2020 07:22:13 GMT
etag:
- '"0x8D7FB114288CFC9"'
last-modified:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
interactions:
- request:
body: null
headers:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:34:46 GMT
x-ms-version:
- '2019-12-12'
method: HEAD
uri: https://storagename.blob.core.windows.net/test2/bla.txt
response:
body:
string: ''
headers:
accept-ranges: bytes
content-disposition: ''
content-length: '0'
content-md5: 1B2M2Y8AsgTpgAmY7PhCfg==
content-type: application/octet-stream
date: Thu, 04 Jun 2020 07:34:46 GMT
etag: '"0x8D7FB118A463E24"'
last-modified: Mon, 18 May 2020 09:55:04 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-access-tier: Hot
x-ms-access-tier-inferred: 'true'
x-ms-blob-type: BlockBlob
x-ms-copy-completion-time: Mon, 18 May 2020 09:55:04 GMT
x-ms-copy-id: 47d2f0e0-9739-42f5-ad74-8359dbb0c2ec
x-ms-copy-progress: 0/0
x-ms-copy-source: https://ortestsaccountcbn1.blob.core.windows.net/test1/bla.txt?versionid=2020-05-18T09:53:04.5502688Z&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacup&se=2020-05-19T09%3A13%3A27.6586322Z&spr=https
x-ms-copy-status: success
x-ms-creation-time: Mon, 18 May 2020 09:55:04 GMT
x-ms-lease-state: available
x-ms-lease-status: unlocked
x-ms-or-policy-id: fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80
x-ms-server-encrypted: 'true'
x-ms-version: '2019-12-12'
status:
code: 200
message: OK
url: https://vbalaorcentral1.blob.core.windows.net/test2/bla.txt
- request:
body: null
headers:
Accept:
- application/xml
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:34:47 GMT
x-ms-range:
- bytes=0-33554431
x-ms-version:
- '2019-12-12'
method: GET
uri: https://storagename.blob.core.windows.net/test2/bla.txt
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>InvalidRange</Code><Message>The\
\ range specified is invalid for the current size of the resource.\nRequestId:4df9364d-a01e-005f-7542-3a6efe000000\n\
Time:2020-06-04T07:34:47.3556477Z</Message></Error>"
headers:
content-length: '249'
content-range: bytes */0
content-type: application/xml
date: Thu, 04 Jun 2020 07:34:46 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code: InvalidRange
x-ms-version: '2019-12-12'
status:
code: 416
message: The range specified is invalid for the current size of the resource.
url: https://vbalaorcentral1.blob.core.windows.net/test2/bla.txt
- request:
body: null
headers:
Accept:
- application/xml
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:34:47 GMT
x-ms-version:
- '2019-12-12'
method: GET
uri: https://storagename.blob.core.windows.net/test2/bla.txt
response:
body:
string: ''
headers:
accept-ranges: bytes
content-disposition: ''
content-length: '0'
content-md5: 1B2M2Y8AsgTpgAmY7PhCfg==
content-type: application/octet-stream
date: Thu, 04 Jun 2020 07:34:46 GMT
etag: '"0x8D7FB118A463E24"'
last-modified: Mon, 18 May 2020 09:55:04 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-blob-type: BlockBlob
x-ms-copy-completion-time: Mon, 18 May 2020 09:55:04 GMT
x-ms-copy-id: 47d2f0e0-9739-42f5-ad74-8359dbb0c2ec
x-ms-copy-progress: 0/0
x-ms-copy-source: https://ortestsaccountcbn1.blob.core.windows.net/test1/bla.txt?versionid=2020-05-18T09:53:04.5502688Z&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacup&se=2020-05-19T09%3A13%3A27.6586322Z&spr=https
x-ms-copy-status: success
x-ms-creation-time: Mon, 18 May 2020 09:55:04 GMT
x-ms-lease-state: available
x-ms-lease-status: unlocked
x-ms-or-policy-id: fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80
x-ms-server-encrypted: 'true'
x-ms-version: '2019-12-12'
status:
code: 200
message: OK
url: https://vbalaorcentral1.blob.core.windows.net/test2/bla.txt
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
interactions:
- request:
body: null
headers:
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:33:24 GMT
x-ms-version:
- '2019-12-12'
method: HEAD
uri: https://storagename.blob.core.windows.net/test1/bla.txt
response:
body:
string: ''
headers:
accept-ranges: bytes
content-disposition: ''
content-length: '0'
content-md5: 1B2M2Y8AsgTpgAmY7PhCfg==
content-type: application/octet-stream
date: Thu, 04 Jun 2020 07:33:24 GMT
etag: '"0x8D7FB114288CFC9"'
last-modified: Mon, 18 May 2020 09:53:04 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-access-tier: Hot
x-ms-access-tier-inferred: 'true'
x-ms-blob-type: BlockBlob
x-ms-creation-time: Mon, 18 May 2020 09:53:04 GMT
x-ms-is-current-version: 'true'
x-ms-lease-state: available
x-ms-lease-status: unlocked
x-ms-or-fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80_105f9aad-f39b-4064-8e47-ccd7937295ca: complete
x-ms-server-encrypted: 'true'
x-ms-version: '2019-12-12'
x-ms-version-id: '2020-05-18T09:53:04.5502688Z'
status:
code: 200
message: OK
url: https://ortestsaccountcbn1.blob.core.windows.net/test1/bla.txt
- request:
body: null
headers:
Accept:
- application/xml
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:33:24 GMT
x-ms-range:
- bytes=0-33554431
x-ms-version:
- '2019-12-12'
method: GET
uri: https://storagename.blob.core.windows.net/test1/bla.txt
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>InvalidRange</Code><Message>The\
\ range specified is invalid for the current size of the resource.\nRequestId:c5120339-d01e-0077-6c42-3a9834000000\n\
Time:2020-06-04T07:33:25.0346242Z</Message></Error>"
headers:
content-length: '249'
content-range: bytes */0
content-type: application/xml
date: Thu, 04 Jun 2020 07:33:24 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-error-code: InvalidRange
x-ms-version: '2019-12-12'
status:
code: 416
message: The range specified is invalid for the current size of the resource.
url: https://ortestsaccountcbn1.blob.core.windows.net/test1/bla.txt
- request:
body: null
headers:
Accept:
- application/xml
User-Agent:
- azsdk-python-storage-blob/12.3.2 Python/3.7.4 (Darwin-19.4.0-x86_64-i386-64bit)
x-ms-date:
- Thu, 04 Jun 2020 07:33:25 GMT
x-ms-version:
- '2019-12-12'
method: GET
uri: https://storagename.blob.core.windows.net/test1/bla.txt
response:
body:
string: ''
headers:
accept-ranges: bytes
content-disposition: ''
content-length: '0'
content-md5: 1B2M2Y8AsgTpgAmY7PhCfg==
content-type: application/octet-stream
date: Thu, 04 Jun 2020 07:33:24 GMT
etag: '"0x8D7FB114288CFC9"'
last-modified: Mon, 18 May 2020 09:53:04 GMT
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-blob-type: BlockBlob
x-ms-creation-time: Mon, 18 May 2020 09:53:04 GMT
x-ms-is-current-version: 'true'
x-ms-lease-state: available
x-ms-lease-status: unlocked
x-ms-or-fd2da1b9-56f5-45ff-9eb6-310e6dfc2c80_105f9aad-f39b-4064-8e47-ccd7937295ca: complete
x-ms-server-encrypted: 'true'
x-ms-version: '2019-12-12'
x-ms-version-id: '2020-05-18T09:53:04.5502688Z'
status:
code: 200
message: OK
url: https://ortestsaccountcbn1.blob.core.windows.net/test1/bla.txt
version: 1
Loading

0 comments on commit 8ef4eab

Please sign in to comment.