@@ -1244,8 +1244,9 @@ def test_export_entities_use_cached_wrapped_rpc():
1244
1244
# Establish that the underlying gRPC stub method was called.
1245
1245
assert mock_rpc .call_count == 1
1246
1246
1247
- # Operation methods build a cached wrapper on first rpc call
1248
- # subsequent calls should use the cached wrapper
1247
+ # Operation methods call wrapper_fn to build a cached
1248
+ # client._transport.operations_client instance on first rpc call.
1249
+ # Subsequent calls should use the cached wrapper
1249
1250
wrapper_fn .reset_mock ()
1250
1251
1251
1252
client .export_entities (request )
@@ -1299,26 +1300,28 @@ async def test_export_entities_async_use_cached_wrapped_rpc(
1299
1300
)
1300
1301
1301
1302
# Replace cached wrapped function with mock
1302
- mock_object = mock .AsyncMock ()
1303
+ mock_rpc = mock .AsyncMock ()
1304
+ mock_rpc .return_value = mock .Mock ()
1303
1305
client ._client ._transport ._wrapped_methods [
1304
1306
client ._client ._transport .export_entities
1305
- ] = mock_object
1307
+ ] = mock_rpc
1306
1308
1307
1309
request = {}
1308
1310
await client .export_entities (request )
1309
1311
1310
1312
# Establish that the underlying gRPC stub method was called.
1311
- assert mock_object .call_count == 1
1313
+ assert mock_rpc .call_count == 1
1312
1314
1313
- # Operation methods build a cached wrapper on first rpc call
1314
- # subsequent calls should use the cached wrapper
1315
+ # Operation methods call wrapper_fn to build a cached
1316
+ # client._transport.operations_client instance on first rpc call.
1317
+ # Subsequent calls should use the cached wrapper
1315
1318
wrapper_fn .reset_mock ()
1316
1319
1317
1320
await client .export_entities (request )
1318
1321
1319
1322
# Establish that a new wrapper was not created for this call
1320
1323
assert wrapper_fn .call_count == 0
1321
- assert mock_object .call_count == 2
1324
+ assert mock_rpc .call_count == 2
1322
1325
1323
1326
1324
1327
@pytest .mark .asyncio
@@ -1640,8 +1643,9 @@ def test_import_entities_use_cached_wrapped_rpc():
1640
1643
# Establish that the underlying gRPC stub method was called.
1641
1644
assert mock_rpc .call_count == 1
1642
1645
1643
- # Operation methods build a cached wrapper on first rpc call
1644
- # subsequent calls should use the cached wrapper
1646
+ # Operation methods call wrapper_fn to build a cached
1647
+ # client._transport.operations_client instance on first rpc call.
1648
+ # Subsequent calls should use the cached wrapper
1645
1649
wrapper_fn .reset_mock ()
1646
1650
1647
1651
client .import_entities (request )
@@ -1695,26 +1699,28 @@ async def test_import_entities_async_use_cached_wrapped_rpc(
1695
1699
)
1696
1700
1697
1701
# Replace cached wrapped function with mock
1698
- mock_object = mock .AsyncMock ()
1702
+ mock_rpc = mock .AsyncMock ()
1703
+ mock_rpc .return_value = mock .Mock ()
1699
1704
client ._client ._transport ._wrapped_methods [
1700
1705
client ._client ._transport .import_entities
1701
- ] = mock_object
1706
+ ] = mock_rpc
1702
1707
1703
1708
request = {}
1704
1709
await client .import_entities (request )
1705
1710
1706
1711
# Establish that the underlying gRPC stub method was called.
1707
- assert mock_object .call_count == 1
1712
+ assert mock_rpc .call_count == 1
1708
1713
1709
- # Operation methods build a cached wrapper on first rpc call
1710
- # subsequent calls should use the cached wrapper
1714
+ # Operation methods call wrapper_fn to build a cached
1715
+ # client._transport.operations_client instance on first rpc call.
1716
+ # Subsequent calls should use the cached wrapper
1711
1717
wrapper_fn .reset_mock ()
1712
1718
1713
1719
await client .import_entities (request )
1714
1720
1715
1721
# Establish that a new wrapper was not created for this call
1716
1722
assert wrapper_fn .call_count == 0
1717
- assert mock_object .call_count == 2
1723
+ assert mock_rpc .call_count == 2
1718
1724
1719
1725
1720
1726
@pytest .mark .asyncio
@@ -2034,8 +2040,9 @@ def test_create_index_use_cached_wrapped_rpc():
2034
2040
# Establish that the underlying gRPC stub method was called.
2035
2041
assert mock_rpc .call_count == 1
2036
2042
2037
- # Operation methods build a cached wrapper on first rpc call
2038
- # subsequent calls should use the cached wrapper
2043
+ # Operation methods call wrapper_fn to build a cached
2044
+ # client._transport.operations_client instance on first rpc call.
2045
+ # Subsequent calls should use the cached wrapper
2039
2046
wrapper_fn .reset_mock ()
2040
2047
2041
2048
client .create_index (request )
@@ -2089,26 +2096,28 @@ async def test_create_index_async_use_cached_wrapped_rpc(
2089
2096
)
2090
2097
2091
2098
# Replace cached wrapped function with mock
2092
- mock_object = mock .AsyncMock ()
2099
+ mock_rpc = mock .AsyncMock ()
2100
+ mock_rpc .return_value = mock .Mock ()
2093
2101
client ._client ._transport ._wrapped_methods [
2094
2102
client ._client ._transport .create_index
2095
- ] = mock_object
2103
+ ] = mock_rpc
2096
2104
2097
2105
request = {}
2098
2106
await client .create_index (request )
2099
2107
2100
2108
# Establish that the underlying gRPC stub method was called.
2101
- assert mock_object .call_count == 1
2109
+ assert mock_rpc .call_count == 1
2102
2110
2103
- # Operation methods build a cached wrapper on first rpc call
2104
- # subsequent calls should use the cached wrapper
2111
+ # Operation methods call wrapper_fn to build a cached
2112
+ # client._transport.operations_client instance on first rpc call.
2113
+ # Subsequent calls should use the cached wrapper
2105
2114
wrapper_fn .reset_mock ()
2106
2115
2107
2116
await client .create_index (request )
2108
2117
2109
2118
# Establish that a new wrapper was not created for this call
2110
2119
assert wrapper_fn .call_count == 0
2111
- assert mock_object .call_count == 2
2120
+ assert mock_rpc .call_count == 2
2112
2121
2113
2122
2114
2123
@pytest .mark .asyncio
@@ -2318,8 +2327,9 @@ def test_delete_index_use_cached_wrapped_rpc():
2318
2327
# Establish that the underlying gRPC stub method was called.
2319
2328
assert mock_rpc .call_count == 1
2320
2329
2321
- # Operation methods build a cached wrapper on first rpc call
2322
- # subsequent calls should use the cached wrapper
2330
+ # Operation methods call wrapper_fn to build a cached
2331
+ # client._transport.operations_client instance on first rpc call.
2332
+ # Subsequent calls should use the cached wrapper
2323
2333
wrapper_fn .reset_mock ()
2324
2334
2325
2335
client .delete_index (request )
@@ -2373,26 +2383,28 @@ async def test_delete_index_async_use_cached_wrapped_rpc(
2373
2383
)
2374
2384
2375
2385
# Replace cached wrapped function with mock
2376
- mock_object = mock .AsyncMock ()
2386
+ mock_rpc = mock .AsyncMock ()
2387
+ mock_rpc .return_value = mock .Mock ()
2377
2388
client ._client ._transport ._wrapped_methods [
2378
2389
client ._client ._transport .delete_index
2379
- ] = mock_object
2390
+ ] = mock_rpc
2380
2391
2381
2392
request = {}
2382
2393
await client .delete_index (request )
2383
2394
2384
2395
# Establish that the underlying gRPC stub method was called.
2385
- assert mock_object .call_count == 1
2396
+ assert mock_rpc .call_count == 1
2386
2397
2387
- # Operation methods build a cached wrapper on first rpc call
2388
- # subsequent calls should use the cached wrapper
2398
+ # Operation methods call wrapper_fn to build a cached
2399
+ # client._transport.operations_client instance on first rpc call.
2400
+ # Subsequent calls should use the cached wrapper
2389
2401
wrapper_fn .reset_mock ()
2390
2402
2391
2403
await client .delete_index (request )
2392
2404
2393
2405
# Establish that a new wrapper was not created for this call
2394
2406
assert wrapper_fn .call_count == 0
2395
- assert mock_object .call_count == 2
2407
+ assert mock_rpc .call_count == 2
2396
2408
2397
2409
2398
2410
@pytest .mark .asyncio
@@ -2670,22 +2682,23 @@ async def test_get_index_async_use_cached_wrapped_rpc(transport: str = "grpc_asy
2670
2682
)
2671
2683
2672
2684
# Replace cached wrapped function with mock
2673
- mock_object = mock .AsyncMock ()
2685
+ mock_rpc = mock .AsyncMock ()
2686
+ mock_rpc .return_value = mock .Mock ()
2674
2687
client ._client ._transport ._wrapped_methods [
2675
2688
client ._client ._transport .get_index
2676
- ] = mock_object
2689
+ ] = mock_rpc
2677
2690
2678
2691
request = {}
2679
2692
await client .get_index (request )
2680
2693
2681
2694
# Establish that the underlying gRPC stub method was called.
2682
- assert mock_object .call_count == 1
2695
+ assert mock_rpc .call_count == 1
2683
2696
2684
2697
await client .get_index (request )
2685
2698
2686
2699
# Establish that a new wrapper was not created for this call
2687
2700
assert wrapper_fn .call_count == 0
2688
- assert mock_object .call_count == 2
2701
+ assert mock_rpc .call_count == 2
2689
2702
2690
2703
2691
2704
@pytest .mark .asyncio
@@ -2964,22 +2977,23 @@ async def test_list_indexes_async_use_cached_wrapped_rpc(
2964
2977
)
2965
2978
2966
2979
# Replace cached wrapped function with mock
2967
- mock_object = mock .AsyncMock ()
2980
+ mock_rpc = mock .AsyncMock ()
2981
+ mock_rpc .return_value = mock .Mock ()
2968
2982
client ._client ._transport ._wrapped_methods [
2969
2983
client ._client ._transport .list_indexes
2970
- ] = mock_object
2984
+ ] = mock_rpc
2971
2985
2972
2986
request = {}
2973
2987
await client .list_indexes (request )
2974
2988
2975
2989
# Establish that the underlying gRPC stub method was called.
2976
- assert mock_object .call_count == 1
2990
+ assert mock_rpc .call_count == 1
2977
2991
2978
2992
await client .list_indexes (request )
2979
2993
2980
2994
# Establish that a new wrapper was not created for this call
2981
2995
assert wrapper_fn .call_count == 0
2982
- assert mock_object .call_count == 2
2996
+ assert mock_rpc .call_count == 2
2983
2997
2984
2998
2985
2999
@pytest .mark .asyncio
0 commit comments