-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify JSON attributes in Key Vault test playback (#9918)
- Loading branch information
Showing
9 changed files
with
213 additions
and
217 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
sdk/keyvault/azure-keyvault-certificates/tests/_shared/json_attribute_matcher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
import json | ||
|
||
import six | ||
|
||
_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "") | ||
|
||
|
||
def json_attribute_matcher(r1, r2): | ||
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values).""" | ||
|
||
if _has_json_body(r1) and _has_json_body(r2): | ||
c1 = json.loads(six.ensure_str(r1.body)) | ||
c2 = json.loads(six.ensure_str(r2.body)) | ||
assert sorted(c1.keys()) == sorted(c2.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
sdk/keyvault/azure-keyvault-keys/tests/_shared/json_attribute_matcher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ------------------------------------ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
import json | ||
|
||
import six | ||
|
||
_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "") | ||
|
||
|
||
def json_attribute_matcher(r1, r2): | ||
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values).""" | ||
|
||
if _has_json_body(r1) and _has_json_body(r2): | ||
c1 = json.loads(six.ensure_str(r1.body)) | ||
c2 = json.loads(six.ensure_str(r2.body)) | ||
assert sorted(c1.keys()) == sorted(c2.keys()) |
Oops, something went wrong.