Skip to content

Commit 4ed5666

Browse files
tests:: add unit test to fix coverage (#217)
1 parent 3d072f6 commit 4ed5666

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/unit/test_blob.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,25 @@ def test_download_as_string_w_response_headers(self):
14821482
self.assertEqual(blob.md5_hash, "CS9tHYTtyFntzj7B9nkkJQ")
14831483
self.assertEqual(blob.crc32c, "4gcgLQ")
14841484

1485+
def test_download_as_string_w_hash_response_header_none(self):
1486+
blob_name = "blob-name"
1487+
client = mock.Mock(spec=["_http"])
1488+
bucket = _Bucket(client)
1489+
media_link = "http://example.com/media/"
1490+
properties = {"mediaLink": media_link}
1491+
blob = self._make_one(blob_name, bucket=bucket, properties=properties)
1492+
1493+
response = self._mock_requests_response(
1494+
http_client.OK,
1495+
headers={"X-Goog-Hash": ""},
1496+
# { "x": 5 } gzipped
1497+
content=b"\x1f\x8b\x08\x00\xcfo\x17_\x02\xff\xabVP\xaaP\xb2R0U\xa8\x05\x00\xa1\xcaQ\x93\n\x00\x00\x00",
1498+
)
1499+
blob._extract_headers_from_download(response)
1500+
1501+
self.assertIsNone(blob.md5_hash)
1502+
self.assertIsNone(blob.crc32c)
1503+
14851504
def test_download_as_string_w_generation_match(self):
14861505
GENERATION_NUMBER = 6
14871506
MEDIA_LINK = "http://example.com/media/"

0 commit comments

Comments
 (0)