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

Commit 42e55ed

Browse files
chore: use gapic-generator-python 0.58.4 (#169)
* 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 8681b1f commit 42e55ed

4 files changed

Lines changed: 62 additions & 128 deletions

File tree

google/cloud/scheduler_v1/services/cloud_scheduler/transports/base.py

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

google/cloud/scheduler_v1beta1/services/cloud_scheduler/transports/base.py

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

tests/unit/gapic/scheduler_v1/test_cloud_scheduler.py

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,20 @@ def test_cloud_scheduler_client_client_options(
254254
# unsupported value.
255255
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
256256
with pytest.raises(MutualTLSChannelError):
257-
client = client_class()
257+
client = client_class(transport=transport_name)
258258

259259
# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
260260
with mock.patch.dict(
261261
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
262262
):
263263
with pytest.raises(ValueError):
264-
client = client_class()
264+
client = client_class(transport=transport_name)
265265

266266
# Check the case quota_project_id is provided
267267
options = client_options.ClientOptions(quota_project_id="octopus")
268268
with mock.patch.object(transport_class, "__init__") as patched:
269269
patched.return_value = None
270-
client = client_class(transport=transport_name, client_options=options)
270+
client = client_class(client_options=options, transport=transport_name)
271271
patched.assert_called_once_with(
272272
credentials=None,
273273
credentials_file=None,
@@ -326,7 +326,7 @@ def test_cloud_scheduler_client_mtls_env_auto(
326326
)
327327
with mock.patch.object(transport_class, "__init__") as patched:
328328
patched.return_value = None
329-
client = client_class(transport=transport_name, client_options=options)
329+
client = client_class(client_options=options, transport=transport_name)
330330

331331
if use_client_cert_env == "false":
332332
expected_client_cert_source = None
@@ -421,7 +421,7 @@ def test_cloud_scheduler_client_client_options_scopes(
421421
options = client_options.ClientOptions(scopes=["1", "2"],)
422422
with mock.patch.object(transport_class, "__init__") as patched:
423423
patched.return_value = None
424-
client = client_class(transport=transport_name, client_options=options)
424+
client = client_class(client_options=options, transport=transport_name)
425425
patched.assert_called_once_with(
426426
credentials=None,
427427
credentials_file=None,
@@ -452,7 +452,7 @@ def test_cloud_scheduler_client_client_options_credentials_file(
452452
options = client_options.ClientOptions(credentials_file="credentials.json")
453453
with mock.patch.object(transport_class, "__init__") as patched:
454454
patched.return_value = None
455-
client = client_class(transport=transport_name, client_options=options)
455+
client = client_class(client_options=options, transport=transport_name)
456456
patched.assert_called_once_with(
457457
credentials=None,
458458
credentials_file="credentials.json",
@@ -485,9 +485,8 @@ def test_cloud_scheduler_client_client_options_from_dict():
485485
)
486486

487487

488-
def test_list_jobs(
489-
transport: str = "grpc", request_type=cloudscheduler.ListJobsRequest
490-
):
488+
@pytest.mark.parametrize("request_type", [cloudscheduler.ListJobsRequest, dict,])
489+
def test_list_jobs(request_type, transport: str = "grpc"):
491490
client = CloudSchedulerClient(
492491
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
493492
)
@@ -514,10 +513,6 @@ def test_list_jobs(
514513
assert response.next_page_token == "next_page_token_value"
515514

516515

517-
def test_list_jobs_from_dict():
518-
test_list_jobs(request_type=dict)
519-
520-
521516
def test_list_jobs_empty_call():
522517
# This test is a coverage failsafe to make sure that totally empty calls,
523518
# i.e. request == None and no flattened fields passed, work.
@@ -693,8 +688,10 @@ async def test_list_jobs_flattened_error_async():
693688
)
694689

695690

696-
def test_list_jobs_pager():
697-
client = CloudSchedulerClient(credentials=ga_credentials.AnonymousCredentials,)
691+
def test_list_jobs_pager(transport_name: str = "grpc"):
692+
client = CloudSchedulerClient(
693+
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
694+
)
698695

699696
# Mock the actual call within the gRPC stub, and fake the request.
700697
with mock.patch.object(type(client.transport.list_jobs), "__call__") as call:
@@ -722,8 +719,10 @@ def test_list_jobs_pager():
722719
assert all(isinstance(i, job.Job) for i in results)
723720

724721

725-
def test_list_jobs_pages():
726-
client = CloudSchedulerClient(credentials=ga_credentials.AnonymousCredentials,)
722+
def test_list_jobs_pages(transport_name: str = "grpc"):
723+
client = CloudSchedulerClient(
724+
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
725+
)
727726

728727
# Mock the actual call within the gRPC stub, and fake the request.
729728
with mock.patch.object(type(client.transport.list_jobs), "__call__") as call:
@@ -795,7 +794,8 @@ async def test_list_jobs_async_pages():
795794
assert page_.raw_page.next_page_token == token
796795

797796

798-
def test_get_job(transport: str = "grpc", request_type=cloudscheduler.GetJobRequest):
797+
@pytest.mark.parametrize("request_type", [cloudscheduler.GetJobRequest, dict,])
798+
def test_get_job(request_type, transport: str = "grpc"):
799799
client = CloudSchedulerClient(
800800
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
801801
)
@@ -831,10 +831,6 @@ def test_get_job(transport: str = "grpc", request_type=cloudscheduler.GetJobRequ
831831
assert response.state == job.Job.State.ENABLED
832832

833833

834-
def test_get_job_from_dict():
835-
test_get_job(request_type=dict)
836-
837-
838834
def test_get_job_empty_call():
839835
# This test is a coverage failsafe to make sure that totally empty calls,
840836
# i.e. request == None and no flattened fields passed, work.
@@ -1016,9 +1012,8 @@ async def test_get_job_flattened_error_async():
10161012
)
10171013

10181014

1019-
def test_create_job(
1020-
transport: str = "grpc", request_type=cloudscheduler.CreateJobRequest
1021-
):
1015+
@pytest.mark.parametrize("request_type", [cloudscheduler.CreateJobRequest, dict,])
1016+
def test_create_job(request_type, transport: str = "grpc"):
10221017
client = CloudSchedulerClient(
10231018
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
10241019
)
@@ -1054,10 +1049,6 @@ def test_create_job(
10541049
assert response.state == gcs_job.Job.State.ENABLED
10551050

10561051

1057-
def test_create_job_from_dict():
1058-
test_create_job(request_type=dict)
1059-
1060-
10611052
def test_create_job_empty_call():
10621053
# This test is a coverage failsafe to make sure that totally empty calls,
10631054
# i.e. request == None and no flattened fields passed, work.
@@ -1253,9 +1244,8 @@ async def test_create_job_flattened_error_async():
12531244
)
12541245

12551246

1256-
def test_update_job(
1257-
transport: str = "grpc", request_type=cloudscheduler.UpdateJobRequest
1258-
):
1247+
@pytest.mark.parametrize("request_type", [cloudscheduler.UpdateJobRequest, dict,])
1248+
def test_update_job(request_type, transport: str = "grpc"):
12591249
client = CloudSchedulerClient(
12601250
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
12611251
)
@@ -1291,10 +1281,6 @@ def test_update_job(
12911281
assert response.state == gcs_job.Job.State.ENABLED
12921282

12931283

1294-
def test_update_job_from_dict():
1295-
test_update_job(request_type=dict)
1296-
1297-
12981284
def test_update_job_empty_call():
12991285
# This test is a coverage failsafe to make sure that totally empty calls,
13001286
# i.e. request == None and no flattened fields passed, work.
@@ -1492,9 +1478,8 @@ async def test_update_job_flattened_error_async():
14921478
)
14931479

14941480

1495-
def test_delete_job(
1496-
transport: str = "grpc", request_type=cloudscheduler.DeleteJobRequest
1497-
):
1481+
@pytest.mark.parametrize("request_type", [cloudscheduler.DeleteJobRequest, dict,])
1482+
def test_delete_job(request_type, transport: str = "grpc"):
14981483
client = CloudSchedulerClient(
14991484
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
15001485
)
@@ -1518,10 +1503,6 @@ def test_delete_job(
15181503
assert response is None
15191504

15201505

1521-
def test_delete_job_from_dict():
1522-
test_delete_job(request_type=dict)
1523-
1524-
15251506
def test_delete_job_empty_call():
15261507
# This test is a coverage failsafe to make sure that totally empty calls,
15271508
# i.e. request == None and no flattened fields passed, work.
@@ -1690,9 +1671,8 @@ async def test_delete_job_flattened_error_async():
16901671
)
16911672

16921673

1693-
def test_pause_job(
1694-
transport: str = "grpc", request_type=cloudscheduler.PauseJobRequest
1695-
):
1674+
@pytest.mark.parametrize("request_type", [cloudscheduler.PauseJobRequest, dict,])
1675+
def test_pause_job(request_type, transport: str = "grpc"):
16961676
client = CloudSchedulerClient(
16971677
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
16981678
)
@@ -1728,10 +1708,6 @@ def test_pause_job(
17281708
assert response.state == job.Job.State.ENABLED
17291709

17301710

1731-
def test_pause_job_from_dict():
1732-
test_pause_job(request_type=dict)
1733-
1734-
17351711
def test_pause_job_empty_call():
17361712
# This test is a coverage failsafe to make sure that totally empty calls,
17371713
# i.e. request == None and no flattened fields passed, work.
@@ -1913,9 +1889,8 @@ async def test_pause_job_flattened_error_async():
19131889
)
19141890

19151891

1916-
def test_resume_job(
1917-
transport: str = "grpc", request_type=cloudscheduler.ResumeJobRequest
1918-
):
1892+
@pytest.mark.parametrize("request_type", [cloudscheduler.ResumeJobRequest, dict,])
1893+
def test_resume_job(request_type, transport: str = "grpc"):
19191894
client = CloudSchedulerClient(
19201895
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
19211896
)
@@ -1951,10 +1926,6 @@ def test_resume_job(
19511926
assert response.state == job.Job.State.ENABLED
19521927

19531928

1954-
def test_resume_job_from_dict():
1955-
test_resume_job(request_type=dict)
1956-
1957-
19581929
def test_resume_job_empty_call():
19591930
# This test is a coverage failsafe to make sure that totally empty calls,
19601931
# i.e. request == None and no flattened fields passed, work.
@@ -2136,7 +2107,8 @@ async def test_resume_job_flattened_error_async():
21362107
)
21372108

21382109

2139-
def test_run_job(transport: str = "grpc", request_type=cloudscheduler.RunJobRequest):
2110+
@pytest.mark.parametrize("request_type", [cloudscheduler.RunJobRequest, dict,])
2111+
def test_run_job(request_type, transport: str = "grpc"):
21402112
client = CloudSchedulerClient(
21412113
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
21422114
)
@@ -2172,10 +2144,6 @@ def test_run_job(transport: str = "grpc", request_type=cloudscheduler.RunJobRequ
21722144
assert response.state == job.Job.State.ENABLED
21732145

21742146

2175-
def test_run_job_from_dict():
2176-
test_run_job(request_type=dict)
2177-
2178-
21792147
def test_run_job_empty_call():
21802148
# This test is a coverage failsafe to make sure that totally empty calls,
21812149
# i.e. request == None and no flattened fields passed, work.
@@ -2898,7 +2866,7 @@ def test_parse_common_location_path():
28982866
assert expected == actual
28992867

29002868

2901-
def test_client_withDEFAULT_CLIENT_INFO():
2869+
def test_client_with_default_client_info():
29022870
client_info = gapic_v1.client_info.ClientInfo()
29032871

29042872
with mock.patch.object(

0 commit comments

Comments
 (0)