From 93bb656c15b0b6a50f9ee5aff711b703fa31e99d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 14:09:31 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#24) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 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 Co-authored-by: Anthonios Partheniou --- .../transports/base.py | 1 - .../test_cloud_filestore_manager.py | 151 +++++++----------- 2 files changed, 59 insertions(+), 93 deletions(-) diff --git a/packages/google-cloud-filestore/google/cloud/filestore_v1/services/cloud_filestore_manager/transports/base.py b/packages/google-cloud-filestore/google/cloud/filestore_v1/services/cloud_filestore_manager/transports/base.py index 95e0ab5f4ec8..adeb8ab9781b 100644 --- a/packages/google-cloud-filestore/google/cloud/filestore_v1/services/cloud_filestore_manager/transports/base.py +++ b/packages/google-cloud-filestore/google/cloud/filestore_v1/services/cloud_filestore_manager/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/packages/google-cloud-filestore/tests/unit/gapic/filestore_v1/test_cloud_filestore_manager.py b/packages/google-cloud-filestore/tests/unit/gapic/filestore_v1/test_cloud_filestore_manager.py index 2612626d7b85..41ad90223a2f 100644 --- a/packages/google-cloud-filestore/tests/unit/gapic/filestore_v1/test_cloud_filestore_manager.py +++ b/packages/google-cloud-filestore/tests/unit/gapic/filestore_v1/test_cloud_filestore_manager.py @@ -263,20 +263,20 @@ def test_cloud_filestore_manager_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -345,7 +345,7 @@ def test_cloud_filestore_manager_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -444,7 +444,7 @@ def test_cloud_filestore_manager_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -479,7 +479,7 @@ def test_cloud_filestore_manager_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -512,9 +512,10 @@ def test_cloud_filestore_manager_client_client_options_from_dict(): ) -def test_list_instances( - transport: str = "grpc", request_type=cloud_filestore_service.ListInstancesRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.ListInstancesRequest, dict,] +) +def test_list_instances(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -542,10 +543,6 @@ def test_list_instances( assert response.unreachable == ["unreachable_value"] -def test_list_instances_from_dict(): - test_list_instances(request_type=dict) - - def test_list_instances_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -732,9 +729,9 @@ async def test_list_instances_flattened_error_async(): ) -def test_list_instances_pager(): +def test_list_instances_pager(transport_name: str = "grpc"): client = CloudFilestoreManagerClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -777,9 +774,9 @@ def test_list_instances_pager(): assert all(isinstance(i, cloud_filestore_service.Instance) for i in results) -def test_list_instances_pages(): +def test_list_instances_pages(transport_name: str = "grpc"): client = CloudFilestoreManagerClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -898,9 +895,10 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=cloud_filestore_service.GetInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.GetInstanceRequest, dict,] +) +def test_get_instance(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -937,10 +935,6 @@ def test_get_instance( assert response.etag == "etag_value" -def test_get_instance_from_dict(): - test_get_instance(request_type=dict) - - def test_get_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1135,9 +1129,10 @@ async def test_get_instance_flattened_error_async(): ) -def test_create_instance( - transport: str = "grpc", request_type=cloud_filestore_service.CreateInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.CreateInstanceRequest, dict,] +) +def test_create_instance(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1161,10 +1156,6 @@ def test_create_instance( assert isinstance(response, future.Future) -def test_create_instance_from_dict(): - test_create_instance(request_type=dict) - - def test_create_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1372,9 +1363,10 @@ async def test_create_instance_flattened_error_async(): ) -def test_update_instance( - transport: str = "grpc", request_type=cloud_filestore_service.UpdateInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.UpdateInstanceRequest, dict,] +) +def test_update_instance(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1398,10 +1390,6 @@ def test_update_instance( assert isinstance(response, future.Future) -def test_update_instance_from_dict(): - test_update_instance(request_type=dict) - - def test_update_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1603,9 +1591,10 @@ async def test_update_instance_flattened_error_async(): ) -def test_restore_instance( - transport: str = "grpc", request_type=cloud_filestore_service.RestoreInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.RestoreInstanceRequest, dict,] +) +def test_restore_instance(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1629,10 +1618,6 @@ def test_restore_instance( assert isinstance(response, future.Future) -def test_restore_instance_from_dict(): - test_restore_instance(request_type=dict) - - def test_restore_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1738,9 +1723,10 @@ async def test_restore_instance_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_instance( - transport: str = "grpc", request_type=cloud_filestore_service.DeleteInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.DeleteInstanceRequest, dict,] +) +def test_delete_instance(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1764,10 +1750,6 @@ def test_delete_instance( assert isinstance(response, future.Future) -def test_delete_instance_from_dict(): - test_delete_instance(request_type=dict) - - def test_delete_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1949,9 +1931,10 @@ async def test_delete_instance_flattened_error_async(): ) -def test_list_backups( - transport: str = "grpc", request_type=cloud_filestore_service.ListBackupsRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.ListBackupsRequest, dict,] +) +def test_list_backups(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1979,10 +1962,6 @@ def test_list_backups( assert response.unreachable == ["unreachable_value"] -def test_list_backups_from_dict(): - test_list_backups(request_type=dict) - - def test_list_backups_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2169,9 +2148,9 @@ async def test_list_backups_flattened_error_async(): ) -def test_list_backups_pager(): +def test_list_backups_pager(transport_name: str = "grpc"): client = CloudFilestoreManagerClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2214,9 +2193,9 @@ def test_list_backups_pager(): assert all(isinstance(i, cloud_filestore_service.Backup) for i in results) -def test_list_backups_pages(): +def test_list_backups_pages(transport_name: str = "grpc"): client = CloudFilestoreManagerClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2335,9 +2314,10 @@ async def test_list_backups_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_backup( - transport: str = "grpc", request_type=cloud_filestore_service.GetBackupRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.GetBackupRequest, dict,] +) +def test_get_backup(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2382,10 +2362,6 @@ def test_get_backup( assert response.download_bytes == 1502 -def test_get_backup_from_dict(): - test_get_backup(request_type=dict) - - def test_get_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2588,9 +2564,10 @@ async def test_get_backup_flattened_error_async(): ) -def test_create_backup( - transport: str = "grpc", request_type=cloud_filestore_service.CreateBackupRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.CreateBackupRequest, dict,] +) +def test_create_backup(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2614,10 +2591,6 @@ def test_create_backup( assert isinstance(response, future.Future) -def test_create_backup_from_dict(): - test_create_backup(request_type=dict) - - def test_create_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2825,9 +2798,10 @@ async def test_create_backup_flattened_error_async(): ) -def test_delete_backup( - transport: str = "grpc", request_type=cloud_filestore_service.DeleteBackupRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.DeleteBackupRequest, dict,] +) +def test_delete_backup(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2851,10 +2825,6 @@ def test_delete_backup( assert isinstance(response, future.Future) -def test_delete_backup_from_dict(): - test_delete_backup(request_type=dict) - - def test_delete_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3036,9 +3006,10 @@ async def test_delete_backup_flattened_error_async(): ) -def test_update_backup( - transport: str = "grpc", request_type=cloud_filestore_service.UpdateBackupRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_filestore_service.UpdateBackupRequest, dict,] +) +def test_update_backup(request_type, transport: str = "grpc"): client = CloudFilestoreManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3062,10 +3033,6 @@ def test_update_backup( assert isinstance(response, future.Future) -def test_update_backup_from_dict(): - test_update_backup(request_type=dict) - - def test_update_backup_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3846,7 +3813,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object(