Skip to content

Commit 62a2c89

Browse files
committed
add and fix failing unit tests
1 parent 4f3d18e commit 62a2c89

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

google/cloud/storage/_experimental/asyncio/_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import google_crc32c
22

3-
from google.cloud.storage import exceptions
3+
from google.api_core import exceptions
44

55
def raise_if_no_fast_crc32c():
66
"""Check if the C-accelerated version of google-crc32c is available.
@@ -17,4 +17,4 @@ def raise_if_no_fast_crc32c():
1717
"The google-crc32c package is not installed with C support. "
1818
"Bidi reads require the C extension for data integrity checks."
1919
"For more information, see https://github.com/googleapis/python-crc32c."
20-
)
20+
)

tests/unit/asyncio/test_async_appendable_object_writer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pytest
1616
from unittest import mock
1717

18+
from google.api_core import exceptions
1819
from google.cloud.storage._experimental.asyncio.async_appendable_object_writer import (
1920
AsyncAppendableObjectWriter,
2021
)
@@ -85,6 +86,23 @@ def test_init_with_optional_args(mock_write_object_stream, mock_client):
8586
)
8687

8788

89+
@mock.patch("google.cloud.storage._experimental.asyncio._utils.google_crc32c")
90+
@mock.patch(
91+
"google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient.grpc_client"
92+
)
93+
def test_init_raises_if_crc32c_c_extension_is_missing(
94+
mock_grpc_client, mock_google_crc32c
95+
):
96+
mock_google_crc32c.implementation = "python"
97+
98+
with pytest.raises(exceptions.NotFound) as exc_info:
99+
AsyncAppendableObjectWriter(mock_grpc_client, "bucket", "object")
100+
101+
assert "The google-crc32c package is not installed with C support" in str(
102+
exc_info.value
103+
)
104+
105+
88106
@pytest.mark.asyncio
89107
@mock.patch(
90108
"google.cloud.storage._experimental.asyncio.async_appendable_object_writer._AsyncWriteObjectStream"

tests/unit/asyncio/test_async_multi_range_downloader.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,7 @@ async def test_downloading_without_opening_should_throw_error(
349349
assert str(exc.value) == "Underlying bidi-gRPC stream is not open"
350350
assert not mrd.is_stream_open
351351

352-
@mock.patch(
353-
"google.cloud.storage._experimental.asyncio.async_multi_range_downloader.google_crc32c"
354-
)
352+
@mock.patch("google.cloud.storage._experimental.asyncio._utils.google_crc32c")
355353
@mock.patch(
356354
"google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient.grpc_client"
357355
)

0 commit comments

Comments
 (0)