Skip to content

Commit

Permalink
fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 6, 2024
1 parent 249d688 commit 66d7d1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 3 additions & 1 deletion google/cloud/bigtable/data/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ async def close(self, timeout: float = 2.0):
self._channel_refresh_task = None

async def _ping_and_warm_instances(
self, instance_key: _WarmedInstanceKey | None = None, channel: grpc.aio.Channel|None=None
self,
instance_key: _WarmedInstanceKey | None = None,
channel: grpc.aio.Channel | None = None,
) -> list[BaseException | None]:
"""
Prepares the backend for requests on a channel
Expand Down
21 changes: 10 additions & 11 deletions tests/unit/data/_async/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ async def test__ping_and_warm_single_instance(self):
# should only have been called with test instance
assert len(result) == 1
# check grpc call arguments
grpc_call_args = client_mock.transport.grpc_channel.unary_unary().call_args_list
grpc_call_args = (
client_mock.transport.grpc_channel.unary_unary().call_args_list
)
assert len(grpc_call_args) == 1
kwargs = grpc_call_args[0][1]
request = kwargs["request"]
Expand Down Expand Up @@ -348,9 +350,7 @@ async def test__manage_channel_ping_and_warm(self):
ping_and_warm = client_mock._ping_and_warm_instances = AsyncMock()
# should ping and warm old channel then new if sleep > 0
try:
await self._get_target_class()._manage_channel(
client_mock, 10
)
await self._get_target_class()._manage_channel(client_mock, 10)
except asyncio.CancelledError:
pass
# should have called at loop start, and after replacement
Expand Down Expand Up @@ -501,7 +501,10 @@ async def test__register_instance(self):
client_mock, "instance-2", table_mock2
)
assert client_mock._start_background_channel_refresh.call_count == 1
assert client_mock._ping_and_warm_instances.call_args[0][0][0] == "prefix/instance-2"
assert (
client_mock._ping_and_warm_instances.call_args[0][0][0]
== "prefix/instance-2"
)
# but it should call ping and warm with new instance key
assert client_mock._ping_and_warm_instances.call_count == 1
# check for updated lists
Expand Down Expand Up @@ -812,15 +815,11 @@ async def test_get_table_context_manager(self):

@pytest.mark.asyncio
async def test_close(self):
client = self._make_one(
project="project-id", use_emulator=False
)
client = self._make_one(project="project-id", use_emulator=False)
task = client._channel_refresh_task
assert task is not None
assert not task.done()
with mock.patch.object(
client.transport, "close", AsyncMock()
) as close_mock:
with mock.patch.object(client.transport, "close", AsyncMock()) as close_mock:
await client.close()
close_mock.assert_called_once()
close_mock.assert_awaited()
Expand Down

0 comments on commit 66d7d1c

Please sign in to comment.