Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 11, 2024
1 parent c95ca68 commit 008e724
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tests/unit/data/_async/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ async def test__manage_channel_sleeps(
import threading

channel = mock.Mock()
channel.close = mock.AsyncMock()
channel.close = CrossSync.Mock()
with mock.patch.object(random, "uniform") as uniform:
uniform.side_effect = lambda min_, max_: min_
with mock.patch.object(time, "time") as time_mock:
Expand All @@ -438,16 +438,15 @@ async def test__manage_channel_sleeps(
]
client = self._make_client(project="project-id")
client.transport._grpc_channel = channel
with mock.patch.object(client.transport, "replace_channel", return_value=channel):
try:
if refresh_interval is not None:
await client._manage_channel(
refresh_interval, refresh_interval
)
else:
await client._manage_channel()
except asyncio.CancelledError:
pass
try:
if refresh_interval is not None:
await client._manage_channel(
refresh_interval, refresh_interval
)
else:
await client._manage_channel()
except asyncio.CancelledError:
pass
assert sleep.call_count == num_cycles
if CrossSync.is_async:
total_sleep = sum([call[0][0] for call in sleep.call_args_list])
Expand Down Expand Up @@ -1274,7 +1273,7 @@ async def test_call_metadata(self, include_app_profile, fn_name, fn_args, gapic_
client = self._make_client()
# create mock for rpc stub
transport_mock = mock.MagicMock()
rpc_mock = mock.AsyncMock()
rpc_mock = CrossSync.Mock()
transport_mock._wrapped_methods.__getitem__.return_value = rpc_mock
client._gapic_client._client._transport = transport_mock
client._gapic_client._client._is_universe_domain_valid = True
Expand Down

0 comments on commit 008e724

Please sign in to comment.