Skip to content

Commit 4afac87

Browse files
authored
feat: leverage async anonymous credentials in tests (#2105)
1 parent f773c8a commit 4afac87

File tree

11 files changed

+869
-727
lines changed

11 files changed

+869
-727
lines changed

gapic/templates/tests/unit/gapic/%name_%version/%sub/_test_mixins.py.j2

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_delete_operation(transport: str = "grpc"):
7878
)
7979
{% else %}
8080
client = {{ service.async_client_name }}(
81-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
81+
credentials=async_anonymous_credentials(), transport=transport,
8282
)
8383
{% endif %}
8484

@@ -120,7 +120,7 @@ def test_delete_operation_field_headers():
120120
)
121121
{% else %}
122122
client = {{ service.async_client_name }}(
123-
credentials=ga_credentials.AnonymousCredentials(),
123+
credentials=async_anonymous_credentials(),
124124
)
125125
{% endif %}
126126

@@ -164,7 +164,7 @@ def test_delete_operation_from_dict():
164164
)
165165
{% else %}
166166
client = {{ service.async_client_name }}(
167-
credentials=ga_credentials.AnonymousCredentials(),
167+
credentials=async_anonymous_credentials(),
168168
)
169169
{% endif %}
170170
# Mock the actual call within the gRPC stub, and fake the request.
@@ -207,7 +207,7 @@ def test_cancel_operation(transport: str = "grpc"):
207207
)
208208
{% else %}
209209
client = {{ service.async_client_name }}(
210-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
210+
credentials=async_anonymous_credentials(), transport=transport,
211211
)
212212
{% endif %}
213213

@@ -249,7 +249,7 @@ def test_cancel_operation_field_headers():
249249
)
250250
{% else %}
251251
client = {{ service.async_client_name }}(
252-
credentials=ga_credentials.AnonymousCredentials(),
252+
credentials=async_anonymous_credentials(),
253253
)
254254
{% endif %}
255255

@@ -293,7 +293,7 @@ def test_cancel_operation_from_dict():
293293
)
294294
{% else %}
295295
client = {{ service.async_client_name }}(
296-
credentials=ga_credentials.AnonymousCredentials(),
296+
credentials=async_anonymous_credentials(),
297297
)
298298
{% endif %}
299299
# Mock the actual call within the gRPC stub, and fake the request.
@@ -335,7 +335,7 @@ def test_wait_operation(transport: str = "grpc"):
335335
)
336336
{% else %}
337337
client = {{ service.async_client_name }}(
338-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
338+
credentials=async_anonymous_credentials(), transport=transport,
339339
)
340340
{% endif %}
341341

@@ -377,7 +377,7 @@ def test_wait_operation_field_headers():
377377
)
378378
{% else %}
379379
client = {{ service.async_client_name }}(
380-
credentials=ga_credentials.AnonymousCredentials(),
380+
credentials=async_anonymous_credentials(),
381381
)
382382
{% endif %}
383383

@@ -421,7 +421,7 @@ def test_wait_operation_from_dict():
421421
)
422422
{% else %}
423423
client = {{ service.async_client_name }}(
424-
credentials=ga_credentials.AnonymousCredentials(),
424+
credentials=async_anonymous_credentials(),
425425
)
426426
{% endif %}
427427
# Mock the actual call within the gRPC stub, and fake the request.
@@ -464,7 +464,7 @@ def test_get_operation(transport: str = "grpc"):
464464
)
465465
{% else %}
466466
client = {{ service.async_client_name }}(
467-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
467+
credentials=async_anonymous_credentials(), transport=transport,
468468
)
469469
{% endif %}
470470

@@ -506,7 +506,7 @@ def test_get_operation_field_headers():
506506
)
507507
{% else %}
508508
client = {{ service.async_client_name }}(
509-
credentials=ga_credentials.AnonymousCredentials(),
509+
credentials=async_anonymous_credentials(),
510510
)
511511
{% endif %}
512512

@@ -550,7 +550,7 @@ def test_get_operation_from_dict():
550550
)
551551
{% else %}
552552
client = {{ service.async_client_name }}(
553-
credentials=ga_credentials.AnonymousCredentials(),
553+
credentials=async_anonymous_credentials(),
554554
)
555555
{% endif %}
556556
# Mock the actual call within the gRPC stub, and fake the request.
@@ -593,7 +593,7 @@ def test_list_operations(transport: str = "grpc"):
593593
)
594594
{% else %}
595595
client = {{ service.async_client_name }}(
596-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
596+
credentials=async_anonymous_credentials(), transport=transport,
597597
)
598598
{% endif %}
599599

@@ -635,7 +635,7 @@ def test_list_operations_field_headers():
635635
)
636636
{% else %}
637637
client = {{ service.async_client_name }}(
638-
credentials=ga_credentials.AnonymousCredentials(),
638+
credentials=async_anonymous_credentials(),
639639
)
640640
{% endif %}
641641

@@ -679,7 +679,7 @@ def test_list_operations_from_dict():
679679
)
680680
{% else %}
681681
client = {{ service.async_client_name }}(
682-
credentials=ga_credentials.AnonymousCredentials(),
682+
credentials=async_anonymous_credentials(),
683683
)
684684
{% endif %}
685685
# Mock the actual call within the gRPC stub, and fake the request.
@@ -728,7 +728,7 @@ def test_list_locations(transport: str = "grpc"):
728728
)
729729
{% else %}
730730
client = {{ service.async_client_name }}(
731-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
731+
credentials=async_anonymous_credentials(), transport=transport,
732732
)
733733
{% endif %}
734734

@@ -770,7 +770,7 @@ def test_list_locations_field_headers():
770770
)
771771
{% else %}
772772
client = {{ service.async_client_name }}(
773-
credentials=ga_credentials.AnonymousCredentials(),
773+
credentials=async_anonymous_credentials(),
774774
)
775775
{% endif %}
776776

@@ -814,7 +814,7 @@ def test_list_locations_from_dict():
814814
)
815815
{% else %}
816816
client = {{ service.async_client_name }}(
817-
credentials=ga_credentials.AnonymousCredentials(),
817+
credentials=async_anonymous_credentials(),
818818
)
819819
{% endif %}
820820
# Mock the actual call within the gRPC stub, and fake the request.
@@ -859,7 +859,7 @@ def test_get_location(transport: str = "grpc"):
859859
)
860860
{% else %}
861861
client = {{ service.async_client_name }}(
862-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
862+
credentials=async_anonymous_credentials(), transport=transport,
863863
)
864864
{% endif %}
865865

@@ -900,7 +900,7 @@ def test_get_location_field_headers():
900900
credentials=ga_credentials.AnonymousCredentials())
901901
{% else %}
902902
client = {{ service.async_client_name }}(
903-
credentials=ga_credentials.AnonymousCredentials()
903+
credentials=async_anonymous_credentials()
904904
)
905905
{% endif %}
906906

@@ -944,7 +944,7 @@ def test_get_location_from_dict():
944944
)
945945
{% else %}
946946
client = {{ service.async_client_name }}(
947-
credentials=ga_credentials.AnonymousCredentials(),
947+
credentials=async_anonymous_credentials(),
948948
)
949949
{% endif %}
950950
# Mock the actual call within the gRPC stub, and fake the request.
@@ -990,7 +990,7 @@ def test_set_iam_policy(transport: str = "grpc"):
990990
)
991991
{% else %}
992992
client = {{ service.async_client_name }}(
993-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
993+
credentials=async_anonymous_credentials(), transport=transport,
994994
)
995995
{% endif %}
996996

@@ -1038,7 +1038,7 @@ def test_set_iam_policy_field_headers():
10381038
)
10391039
{% else %}
10401040
client = {{ service.async_client_name }}(
1041-
credentials=ga_credentials.AnonymousCredentials(),
1041+
credentials=async_anonymous_credentials(),
10421042
)
10431043
{% endif %}
10441044

@@ -1090,7 +1090,7 @@ def test_set_iam_policy_from_dict():
10901090
@pytest.mark.asyncio
10911091
async def test_set_iam_policy_from_dict_async():
10921092
client = {{ service.async_client_name }}(
1093-
credentials=ga_credentials.AnonymousCredentials(),
1093+
credentials=async_anonymous_credentials(),
10941094
)
10951095
# Mock the actual call within the gRPC stub, and fake the request.
10961096
with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call:
@@ -1141,7 +1141,7 @@ def test_get_iam_policy(transport: str = "grpc"):
11411141
@pytest.mark.asyncio
11421142
async def test_get_iam_policy_async(transport: str = "grpc_asyncio"):
11431143
client = {{ service.async_client_name }}(
1144-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
1144+
credentials=async_anonymous_credentials(), transport=transport,
11451145
)
11461146

11471147
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1202,7 +1202,7 @@ def test_get_iam_policy_field_headers():
12021202
@pytest.mark.asyncio
12031203
async def test_get_iam_policy_field_headers_async():
12041204
client = {{ service.async_client_name }}(
1205-
credentials=ga_credentials.AnonymousCredentials(),
1205+
credentials=async_anonymous_credentials(),
12061206
)
12071207

12081208
# Any value that is part of the HTTP/1.1 URI should be sent as
@@ -1248,7 +1248,7 @@ def test_get_iam_policy_from_dict():
12481248
@pytest.mark.asyncio
12491249
async def test_get_iam_policy_from_dict_async():
12501250
client = {{ service.async_client_name }}(
1251-
credentials=ga_credentials.AnonymousCredentials(),
1251+
credentials=async_anonymous_credentials(),
12521252
)
12531253
# Mock the actual call within the gRPC stub, and fake the request.
12541254
with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call:
@@ -1301,7 +1301,7 @@ def test_test_iam_permissions(transport: str = "grpc"):
13011301
@pytest.mark.asyncio
13021302
async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"):
13031303
client = {{ service.async_client_name }}(
1304-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
1304+
credentials=async_anonymous_credentials(), transport=transport,
13051305
)
13061306

13071307
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1362,7 +1362,7 @@ def test_test_iam_permissions_field_headers():
13621362
@pytest.mark.asyncio
13631363
async def test_test_iam_permissions_field_headers_async():
13641364
client = {{ service.async_client_name }}(
1365-
credentials=ga_credentials.AnonymousCredentials(),
1365+
credentials=async_anonymous_credentials(),
13661366
)
13671367

13681368
# Any value that is part of the HTTP/1.1 URI should be sent as
@@ -1412,7 +1412,7 @@ def test_test_iam_permissions_from_dict():
14121412
@pytest.mark.asyncio
14131413
async def test_test_iam_permissions_from_dict_async():
14141414
client = {{ service.async_client_name }}(
1415-
credentials=ga_credentials.AnonymousCredentials(),
1415+
credentials=async_anonymous_credentials(),
14161416
)
14171417
# Mock the actual call within the gRPC stub, and fake the request.
14181418
with mock.patch.object(
@@ -1449,7 +1449,7 @@ def test_set_iam_policy(transport: str = "grpc"):
14491449
)
14501450
{% else %}
14511451
client = {{ service.async_client_name }}(
1452-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
1452+
credentials=async_anonymous_credentials(), transport=transport,
14531453
)
14541454
{% endif %}
14551455

@@ -1497,7 +1497,7 @@ def test_set_iam_policy_field_headers():
14971497
)
14981498
{% else %}
14991499
client = {{ service.async_client_name }}(
1500-
credentials=ga_credentials.AnonymousCredentials(),
1500+
credentials=async_anonymous_credentials(),
15011501
)
15021502
{% endif %}
15031503

@@ -1549,7 +1549,7 @@ def test_set_iam_policy_from_dict():
15491549
@pytest.mark.asyncio
15501550
async def test_set_iam_policy_from_dict_async():
15511551
client = {{ service.async_client_name }}(
1552-
credentials=ga_credentials.AnonymousCredentials(),
1552+
credentials=async_anonymous_credentials(),
15531553
)
15541554
# Mock the actual call within the gRPC stub, and fake the request.
15551555
with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call:
@@ -1601,7 +1601,7 @@ def test_get_iam_policy(transport: str = "grpc"):
16011601
@pytest.mark.asyncio
16021602
async def test_get_iam_policy_async(transport: str = "grpc_asyncio"):
16031603
client = {{ service.async_client_name }}(
1604-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
1604+
credentials=async_anonymous_credentials(), transport=transport,
16051605
)
16061606

16071607
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1662,7 +1662,7 @@ def test_get_iam_policy_field_headers():
16621662
@pytest.mark.asyncio
16631663
async def test_get_iam_policy_field_headers_async():
16641664
client = {{ service.async_client_name }}(
1665-
credentials=ga_credentials.AnonymousCredentials(),
1665+
credentials=async_anonymous_credentials(),
16661666
)
16671667

16681668
# Any value that is part of the HTTP/1.1 URI should be sent as
@@ -1708,7 +1708,7 @@ def test_get_iam_policy_from_dict():
17081708
@pytest.mark.asyncio
17091709
async def test_get_iam_policy_from_dict_async():
17101710
client = {{ service.async_client_name }}(
1711-
credentials=ga_credentials.AnonymousCredentials(),
1711+
credentials=async_anonymous_credentials(),
17121712
)
17131713
# Mock the actual call within the gRPC stub, and fake the request.
17141714
with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call:
@@ -1762,7 +1762,7 @@ def test_test_iam_permissions(transport: str = "grpc"):
17621762
@pytest.mark.asyncio
17631763
async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"):
17641764
client = {{ service.async_client_name }}(
1765-
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
1765+
credentials=async_anonymous_credentials(), transport=transport,
17661766
)
17671767

17681768
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1823,7 +1823,7 @@ def test_test_iam_permissions_field_headers():
18231823
@pytest.mark.asyncio
18241824
async def test_test_iam_permissions_field_headers_async():
18251825
client = {{ service.async_client_name }}(
1826-
credentials=ga_credentials.AnonymousCredentials(),
1826+
credentials=async_anonymous_credentials(),
18271827
)
18281828

18291829
# Any value that is part of the HTTP/1.1 URI should be sent as
@@ -1873,7 +1873,7 @@ def test_test_iam_permissions_from_dict():
18731873
@pytest.mark.asyncio
18741874
async def test_test_iam_permissions_from_dict_async():
18751875
client = {{ service.async_client_name }}(
1876-
credentials=ga_credentials.AnonymousCredentials(),
1876+
credentials=async_anonymous_credentials(),
18771877
)
18781878
# Mock the actual call within the gRPC stub, and fake the request.
18791879
with mock.patch.object(

0 commit comments

Comments
 (0)