Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 1551159

Browse files
chore: use gapic-generator-python 0.58.4 (#144)
* chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: googleapis/googleapis@73da669 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 6e91a3c commit 1551159

File tree

4 files changed

+66
-150
lines changed

4 files changed

+66
-150
lines changed

google/cloud/redis_v1/services/cloud_redis/transports/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def __init__(
101101
credentials, _ = google.auth.load_credentials_from_file(
102102
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
103103
)
104-
105104
elif credentials is None:
106105
credentials, _ = google.auth.default(
107106
**scopes_kwargs, quota_project_id=quota_project_id

google/cloud/redis_v1beta1/services/cloud_redis/transports/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def __init__(
101101
credentials, _ = google.auth.load_credentials_from_file(
102102
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
103103
)
104-
105104
elif credentials is None:
106105
credentials, _ = google.auth.default(
107106
**scopes_kwargs, quota_project_id=quota_project_id

tests/unit/gapic/redis_v1/test_cloud_redis.py

Lines changed: 33 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,20 @@ def test_cloud_redis_client_client_options(
243243
# unsupported value.
244244
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
245245
with pytest.raises(MutualTLSChannelError):
246-
client = client_class()
246+
client = client_class(transport=transport_name)
247247

248248
# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
249249
with mock.patch.dict(
250250
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
251251
):
252252
with pytest.raises(ValueError):
253-
client = client_class()
253+
client = client_class(transport=transport_name)
254254

255255
# Check the case quota_project_id is provided
256256
options = client_options.ClientOptions(quota_project_id="octopus")
257257
with mock.patch.object(transport_class, "__init__") as patched:
258258
patched.return_value = None
259-
client = client_class(transport=transport_name, client_options=options)
259+
client = client_class(client_options=options, transport=transport_name)
260260
patched.assert_called_once_with(
261261
credentials=None,
262262
credentials_file=None,
@@ -313,7 +313,7 @@ def test_cloud_redis_client_mtls_env_auto(
313313
)
314314
with mock.patch.object(transport_class, "__init__") as patched:
315315
patched.return_value = None
316-
client = client_class(transport=transport_name, client_options=options)
316+
client = client_class(client_options=options, transport=transport_name)
317317

318318
if use_client_cert_env == "false":
319319
expected_client_cert_source = None
@@ -408,7 +408,7 @@ def test_cloud_redis_client_client_options_scopes(
408408
options = client_options.ClientOptions(scopes=["1", "2"],)
409409
with mock.patch.object(transport_class, "__init__") as patched:
410410
patched.return_value = None
411-
client = client_class(transport=transport_name, client_options=options)
411+
client = client_class(client_options=options, transport=transport_name)
412412
patched.assert_called_once_with(
413413
credentials=None,
414414
credentials_file=None,
@@ -439,7 +439,7 @@ def test_cloud_redis_client_client_options_credentials_file(
439439
options = client_options.ClientOptions(credentials_file="credentials.json")
440440
with mock.patch.object(transport_class, "__init__") as patched:
441441
patched.return_value = None
442-
client = client_class(transport=transport_name, client_options=options)
442+
client = client_class(client_options=options, transport=transport_name)
443443
patched.assert_called_once_with(
444444
credentials=None,
445445
credentials_file="credentials.json",
@@ -470,9 +470,8 @@ def test_cloud_redis_client_client_options_from_dict():
470470
)
471471

472472

473-
def test_list_instances(
474-
transport: str = "grpc", request_type=cloud_redis.ListInstancesRequest
475-
):
473+
@pytest.mark.parametrize("request_type", [cloud_redis.ListInstancesRequest, dict,])
474+
def test_list_instances(request_type, transport: str = "grpc"):
476475
client = CloudRedisClient(
477476
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
478477
)
@@ -500,10 +499,6 @@ def test_list_instances(
500499
assert response.unreachable == ["unreachable_value"]
501500

502501

503-
def test_list_instances_from_dict():
504-
test_list_instances(request_type=dict)
505-
506-
507502
def test_list_instances_empty_call():
508503
# This test is a coverage failsafe to make sure that totally empty calls,
509504
# i.e. request == None and no flattened fields passed, work.
@@ -677,8 +672,10 @@ async def test_list_instances_flattened_error_async():
677672
)
678673

679674

680-
def test_list_instances_pager():
681-
client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,)
675+
def test_list_instances_pager(transport_name: str = "grpc"):
676+
client = CloudRedisClient(
677+
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
678+
)
682679

683680
# Mock the actual call within the gRPC stub, and fake the request.
684681
with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
@@ -715,8 +712,10 @@ def test_list_instances_pager():
715712
assert all(isinstance(i, cloud_redis.Instance) for i in results)
716713

717714

718-
def test_list_instances_pages():
719-
client = CloudRedisClient(credentials=ga_credentials.AnonymousCredentials,)
715+
def test_list_instances_pages(transport_name: str = "grpc"):
716+
client = CloudRedisClient(
717+
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
718+
)
720719

721720
# Mock the actual call within the gRPC stub, and fake the request.
722721
with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
@@ -815,9 +814,8 @@ async def test_list_instances_async_pages():
815814
assert page_.raw_page.next_page_token == token
816815

817816

818-
def test_get_instance(
819-
transport: str = "grpc", request_type=cloud_redis.GetInstanceRequest
820-
):
817+
@pytest.mark.parametrize("request_type", [cloud_redis.GetInstanceRequest, dict,])
818+
def test_get_instance(request_type, transport: str = "grpc"):
821819
client = CloudRedisClient(
822820
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
823821
)
@@ -885,10 +883,6 @@ def test_get_instance(
885883
)
886884

887885

888-
def test_get_instance_from_dict():
889-
test_get_instance(request_type=dict)
890-
891-
892886
def test_get_instance_empty_call():
893887
# This test is a coverage failsafe to make sure that totally empty calls,
894888
# i.e. request == None and no flattened fields passed, work.
@@ -1101,9 +1095,8 @@ async def test_get_instance_flattened_error_async():
11011095
)
11021096

11031097

1104-
def test_create_instance(
1105-
transport: str = "grpc", request_type=cloud_redis.CreateInstanceRequest
1106-
):
1098+
@pytest.mark.parametrize("request_type", [cloud_redis.CreateInstanceRequest, dict,])
1099+
def test_create_instance(request_type, transport: str = "grpc"):
11071100
client = CloudRedisClient(
11081101
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
11091102
)
@@ -1127,10 +1120,6 @@ def test_create_instance(
11271120
assert isinstance(response, future.Future)
11281121

11291122

1130-
def test_create_instance_from_dict():
1131-
test_create_instance(request_type=dict)
1132-
1133-
11341123
def test_create_instance_empty_call():
11351124
# This test is a coverage failsafe to make sure that totally empty calls,
11361125
# i.e. request == None and no flattened fields passed, work.
@@ -1325,9 +1314,8 @@ async def test_create_instance_flattened_error_async():
13251314
)
13261315

13271316

1328-
def test_update_instance(
1329-
transport: str = "grpc", request_type=cloud_redis.UpdateInstanceRequest
1330-
):
1317+
@pytest.mark.parametrize("request_type", [cloud_redis.UpdateInstanceRequest, dict,])
1318+
def test_update_instance(request_type, transport: str = "grpc"):
13311319
client = CloudRedisClient(
13321320
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
13331321
)
@@ -1351,10 +1339,6 @@ def test_update_instance(
13511339
assert isinstance(response, future.Future)
13521340

13531341

1354-
def test_update_instance_from_dict():
1355-
test_update_instance(request_type=dict)
1356-
1357-
13581342
def test_update_instance_empty_call():
13591343
# This test is a coverage failsafe to make sure that totally empty calls,
13601344
# i.e. request == None and no flattened fields passed, work.
@@ -1543,9 +1527,8 @@ async def test_update_instance_flattened_error_async():
15431527
)
15441528

15451529

1546-
def test_upgrade_instance(
1547-
transport: str = "grpc", request_type=cloud_redis.UpgradeInstanceRequest
1548-
):
1530+
@pytest.mark.parametrize("request_type", [cloud_redis.UpgradeInstanceRequest, dict,])
1531+
def test_upgrade_instance(request_type, transport: str = "grpc"):
15491532
client = CloudRedisClient(
15501533
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
15511534
)
@@ -1569,10 +1552,6 @@ def test_upgrade_instance(
15691552
assert isinstance(response, future.Future)
15701553

15711554

1572-
def test_upgrade_instance_from_dict():
1573-
test_upgrade_instance(request_type=dict)
1574-
1575-
15761555
def test_upgrade_instance_empty_call():
15771556
# This test is a coverage failsafe to make sure that totally empty calls,
15781557
# i.e. request == None and no flattened fields passed, work.
@@ -1755,9 +1734,8 @@ async def test_upgrade_instance_flattened_error_async():
17551734
)
17561735

17571736

1758-
def test_import_instance(
1759-
transport: str = "grpc", request_type=cloud_redis.ImportInstanceRequest
1760-
):
1737+
@pytest.mark.parametrize("request_type", [cloud_redis.ImportInstanceRequest, dict,])
1738+
def test_import_instance(request_type, transport: str = "grpc"):
17611739
client = CloudRedisClient(
17621740
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
17631741
)
@@ -1781,10 +1759,6 @@ def test_import_instance(
17811759
assert isinstance(response, future.Future)
17821760

17831761

1784-
def test_import_instance_from_dict():
1785-
test_import_instance(request_type=dict)
1786-
1787-
17881762
def test_import_instance_empty_call():
17891763
# This test is a coverage failsafe to make sure that totally empty calls,
17901764
# i.e. request == None and no flattened fields passed, work.
@@ -1981,9 +1955,8 @@ async def test_import_instance_flattened_error_async():
19811955
)
19821956

19831957

1984-
def test_export_instance(
1985-
transport: str = "grpc", request_type=cloud_redis.ExportInstanceRequest
1986-
):
1958+
@pytest.mark.parametrize("request_type", [cloud_redis.ExportInstanceRequest, dict,])
1959+
def test_export_instance(request_type, transport: str = "grpc"):
19871960
client = CloudRedisClient(
19881961
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
19891962
)
@@ -2007,10 +1980,6 @@ def test_export_instance(
20071980
assert isinstance(response, future.Future)
20081981

20091982

2010-
def test_export_instance_from_dict():
2011-
test_export_instance(request_type=dict)
2012-
2013-
20141983
def test_export_instance_empty_call():
20151984
# This test is a coverage failsafe to make sure that totally empty calls,
20161985
# i.e. request == None and no flattened fields passed, work.
@@ -2207,9 +2176,8 @@ async def test_export_instance_flattened_error_async():
22072176
)
22082177

22092178

2210-
def test_failover_instance(
2211-
transport: str = "grpc", request_type=cloud_redis.FailoverInstanceRequest
2212-
):
2179+
@pytest.mark.parametrize("request_type", [cloud_redis.FailoverInstanceRequest, dict,])
2180+
def test_failover_instance(request_type, transport: str = "grpc"):
22132181
client = CloudRedisClient(
22142182
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
22152183
)
@@ -2235,10 +2203,6 @@ def test_failover_instance(
22352203
assert isinstance(response, future.Future)
22362204

22372205

2238-
def test_failover_instance_from_dict():
2239-
test_failover_instance(request_type=dict)
2240-
2241-
22422206
def test_failover_instance_empty_call():
22432207
# This test is a coverage failsafe to make sure that totally empty calls,
22442208
# i.e. request == None and no flattened fields passed, work.
@@ -2439,9 +2403,8 @@ async def test_failover_instance_flattened_error_async():
24392403
)
24402404

24412405

2442-
def test_delete_instance(
2443-
transport: str = "grpc", request_type=cloud_redis.DeleteInstanceRequest
2444-
):
2406+
@pytest.mark.parametrize("request_type", [cloud_redis.DeleteInstanceRequest, dict,])
2407+
def test_delete_instance(request_type, transport: str = "grpc"):
24452408
client = CloudRedisClient(
24462409
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
24472410
)
@@ -2465,10 +2428,6 @@ def test_delete_instance(
24652428
assert isinstance(response, future.Future)
24662429

24672430

2468-
def test_delete_instance_from_dict():
2469-
test_delete_instance(request_type=dict)
2470-
2471-
24722431
def test_delete_instance_empty_call():
24732432
# This test is a coverage failsafe to make sure that totally empty calls,
24742433
# i.e. request == None and no flattened fields passed, work.
@@ -3173,7 +3132,7 @@ def test_parse_common_location_path():
31733132
assert expected == actual
31743133

31753134

3176-
def test_client_withDEFAULT_CLIENT_INFO():
3135+
def test_client_with_default_client_info():
31773136
client_info = gapic_v1.client_info.ClientInfo()
31783137

31793138
with mock.patch.object(

0 commit comments

Comments
 (0)