Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revise and rename is_etag_in_json(data) #483

Merged
merged 10 commits into from Jul 9, 2021
2 changes: 2 additions & 0 deletions google/cloud/storage/retry.py
Expand Up @@ -125,6 +125,8 @@ def is_etag_in_json(data):

Indended for use on calls with relatively short JSON payloads."""
try:
if isinstance(data, dict) and data.get("etag"):
cojenco marked this conversation as resolved.
Show resolved Hide resolved
return True
content = json.loads(data)
if content.get("etag"):
return True
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_retry.py
Expand Up @@ -193,6 +193,11 @@ def test_w_empty_data(self):

self.assertFalse(self._call_fut(data))

def test_w_etag_in_dict(self):
data = {"etag": "123"}

self.assertTrue(self._call_fut(data))


class Test_default_conditional_retry_policies(unittest.TestCase):
def test_is_generation_specified_match_generation_match(self):
Expand Down