From 7e148b552fd5a4904ff19d95235bbc35045480d6 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 7 Jan 2022 13:49:15 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#93) 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 --- .../services/applications/transports/base.py | 1 - .../transports/base.py | 1 - .../authorized_domains/transports/base.py | 1 - .../domain_mappings/transports/base.py | 1 - .../services/firewall/transports/base.py | 1 - .../services/instances/transports/base.py | 1 - .../services/services/transports/base.py | 1 - .../services/versions/transports/base.py | 1 - .../appengine_admin_v1/test_applications.py | 50 ++++------- .../test_authorized_certificates.py | 77 +++++++---------- .../test_authorized_domains.py | 37 +++++---- .../test_domain_mappings.py | 71 ++++++---------- .../gapic/appengine_admin_v1/test_firewall.py | 82 +++++++------------ .../appengine_admin_v1/test_instances.py | 62 ++++++-------- .../gapic/appengine_admin_v1/test_services.py | 60 ++++++-------- .../gapic/appengine_admin_v1/test_versions.py | 69 ++++++---------- 16 files changed, 190 insertions(+), 326 deletions(-) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/base.py index d2d1e1df7509..61624e096cd5 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/base.py @@ -108,7 +108,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-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py index 3f3c2953a7f6..500931585991 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/base.py @@ -107,7 +107,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-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py index 0729c5a35e16..c9bc5fd5d3d4 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/base.py @@ -105,7 +105,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-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py index c3a392d48af8..5b88674cb8c0 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/base.py @@ -108,7 +108,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-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/base.py index 49e3fefa5461..3dbbafee7d00 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/base.py @@ -107,7 +107,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-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/base.py index 171b2a3b3517..14c52fbdfbf7 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/base.py @@ -108,7 +108,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-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/base.py index 5306744aac2b..f92d7cd74b0d 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/base.py @@ -108,7 +108,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-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/base.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/base.py index 075116593079..41bf09117e08 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/base.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/base.py @@ -108,7 +108,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-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py index a99ea93d32ce..8192150bf81e 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py @@ -246,20 +246,20 @@ def test_applications_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, @@ -316,7 +316,7 @@ def test_applications_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 @@ -411,7 +411,7 @@ def test_applications_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, @@ -442,7 +442,7 @@ def test_applications_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", @@ -473,9 +473,8 @@ def test_applications_client_client_options_from_dict(): ) -def test_get_application( - transport: str = "grpc", request_type=appengine.GetApplicationRequest -): +@pytest.mark.parametrize("request_type", [appengine.GetApplicationRequest, dict,]) +def test_get_application(request_type, transport: str = "grpc"): client = ApplicationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -522,10 +521,6 @@ def test_get_application( ) -def test_get_application_from_dict(): - test_get_application(request_type=dict) - - def test_get_application_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. @@ -649,9 +644,8 @@ async def test_get_application_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_application( - transport: str = "grpc", request_type=appengine.CreateApplicationRequest -): +@pytest.mark.parametrize("request_type", [appengine.CreateApplicationRequest, dict,]) +def test_create_application(request_type, transport: str = "grpc"): client = ApplicationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -677,10 +671,6 @@ def test_create_application( assert isinstance(response, future.Future) -def test_create_application_from_dict(): - test_create_application(request_type=dict) - - def test_create_application_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. @@ -734,9 +724,8 @@ async def test_create_application_async_from_dict(): await test_create_application_async(request_type=dict) -def test_update_application( - transport: str = "grpc", request_type=appengine.UpdateApplicationRequest -): +@pytest.mark.parametrize("request_type", [appengine.UpdateApplicationRequest, dict,]) +def test_update_application(request_type, transport: str = "grpc"): client = ApplicationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -762,10 +751,6 @@ def test_update_application( assert isinstance(response, future.Future) -def test_update_application_from_dict(): - test_update_application(request_type=dict) - - def test_update_application_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. @@ -874,9 +859,8 @@ async def test_update_application_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_repair_application( - transport: str = "grpc", request_type=appengine.RepairApplicationRequest -): +@pytest.mark.parametrize("request_type", [appengine.RepairApplicationRequest, dict,]) +def test_repair_application(request_type, transport: str = "grpc"): client = ApplicationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -902,10 +886,6 @@ def test_repair_application( assert isinstance(response, future.Future) -def test_repair_application_from_dict(): - test_repair_application(request_type=dict) - - def test_repair_application_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. @@ -1543,7 +1523,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py index 300dbfa27a32..d9f284b327e4 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py @@ -258,20 +258,20 @@ def test_authorized_certificates_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, @@ -340,7 +340,7 @@ def test_authorized_certificates_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 @@ -439,7 +439,7 @@ def test_authorized_certificates_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, @@ -474,7 +474,7 @@ def test_authorized_certificates_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", @@ -507,9 +507,10 @@ def test_authorized_certificates_client_client_options_from_dict(): ) -def test_list_authorized_certificates( - transport: str = "grpc", request_type=appengine.ListAuthorizedCertificatesRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.ListAuthorizedCertificatesRequest, dict,] +) +def test_list_authorized_certificates(request_type, transport: str = "grpc"): client = AuthorizedCertificatesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -538,10 +539,6 @@ def test_list_authorized_certificates( assert response.next_page_token == "next_page_token_value" -def test_list_authorized_certificates_from_dict(): - test_list_authorized_certificates(request_type=dict) - - def test_list_authorized_certificates_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. @@ -658,9 +655,9 @@ async def test_list_authorized_certificates_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_authorized_certificates_pager(): +def test_list_authorized_certificates_pager(transport_name: str = "grpc"): client = AuthorizedCertificatesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -706,9 +703,9 @@ def test_list_authorized_certificates_pager(): assert all(isinstance(i, certificate.AuthorizedCertificate) for i in results) -def test_list_authorized_certificates_pages(): +def test_list_authorized_certificates_pages(transport_name: str = "grpc"): client = AuthorizedCertificatesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -838,9 +835,10 @@ async def test_list_authorized_certificates_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_authorized_certificate( - transport: str = "grpc", request_type=appengine.GetAuthorizedCertificateRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.GetAuthorizedCertificateRequest, dict,] +) +def test_get_authorized_certificate(request_type, transport: str = "grpc"): client = AuthorizedCertificatesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -879,10 +877,6 @@ def test_get_authorized_certificate( assert response.domain_mappings_count == 2238 -def test_get_authorized_certificate_from_dict(): - test_get_authorized_certificate(request_type=dict) - - def test_get_authorized_certificate_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. @@ -1009,9 +1003,10 @@ async def test_get_authorized_certificate_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_authorized_certificate( - transport: str = "grpc", request_type=appengine.CreateAuthorizedCertificateRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.CreateAuthorizedCertificateRequest, dict,] +) +def test_create_authorized_certificate(request_type, transport: str = "grpc"): client = AuthorizedCertificatesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1050,10 +1045,6 @@ def test_create_authorized_certificate( assert response.domain_mappings_count == 2238 -def test_create_authorized_certificate_from_dict(): - test_create_authorized_certificate(request_type=dict) - - def test_create_authorized_certificate_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. @@ -1180,9 +1171,10 @@ async def test_create_authorized_certificate_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_authorized_certificate( - transport: str = "grpc", request_type=appengine.UpdateAuthorizedCertificateRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.UpdateAuthorizedCertificateRequest, dict,] +) +def test_update_authorized_certificate(request_type, transport: str = "grpc"): client = AuthorizedCertificatesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1221,10 +1213,6 @@ def test_update_authorized_certificate( assert response.domain_mappings_count == 2238 -def test_update_authorized_certificate_from_dict(): - test_update_authorized_certificate(request_type=dict) - - def test_update_authorized_certificate_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. @@ -1351,9 +1339,10 @@ async def test_update_authorized_certificate_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_authorized_certificate( - transport: str = "grpc", request_type=appengine.DeleteAuthorizedCertificateRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.DeleteAuthorizedCertificateRequest, dict,] +) +def test_delete_authorized_certificate(request_type, transport: str = "grpc"): client = AuthorizedCertificatesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1379,10 +1368,6 @@ def test_delete_authorized_certificate( assert response is None -def test_delete_authorized_certificate_from_dict(): - test_delete_authorized_certificate(request_type=dict) - - def test_delete_authorized_certificate_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. @@ -2008,7 +1993,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py index ea2003544657..f852bc7e2406 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py @@ -252,20 +252,20 @@ def test_authorized_domains_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, @@ -334,7 +334,7 @@ def test_authorized_domains_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 @@ -429,7 +429,7 @@ def test_authorized_domains_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, @@ -460,7 +460,7 @@ def test_authorized_domains_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", @@ -493,9 +493,10 @@ def test_authorized_domains_client_client_options_from_dict(): ) -def test_list_authorized_domains( - transport: str = "grpc", request_type=appengine.ListAuthorizedDomainsRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.ListAuthorizedDomainsRequest, dict,] +) +def test_list_authorized_domains(request_type, transport: str = "grpc"): client = AuthorizedDomainsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -524,10 +525,6 @@ def test_list_authorized_domains( assert response.next_page_token == "next_page_token_value" -def test_list_authorized_domains_from_dict(): - test_list_authorized_domains(request_type=dict) - - def test_list_authorized_domains_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. @@ -641,8 +638,10 @@ async def test_list_authorized_domains_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_authorized_domains_pager(): - client = AuthorizedDomainsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_authorized_domains_pager(transport_name: str = "grpc"): + client = AuthorizedDomainsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -681,8 +680,10 @@ def test_list_authorized_domains_pager(): assert all(isinstance(i, domain.AuthorizedDomain) for i in results) -def test_list_authorized_domains_pages(): - client = AuthorizedDomainsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_authorized_domains_pages(transport_name: str = "grpc"): + client = AuthorizedDomainsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1295,7 +1296,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py index 1ed355752eac..e79a31dc3c32 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py @@ -257,20 +257,20 @@ def test_domain_mappings_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, @@ -329,7 +329,7 @@ def test_domain_mappings_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 @@ -424,7 +424,7 @@ def test_domain_mappings_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, @@ -455,7 +455,7 @@ def test_domain_mappings_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", @@ -488,9 +488,8 @@ def test_domain_mappings_client_client_options_from_dict(): ) -def test_list_domain_mappings( - transport: str = "grpc", request_type=appengine.ListDomainMappingsRequest -): +@pytest.mark.parametrize("request_type", [appengine.ListDomainMappingsRequest, dict,]) +def test_list_domain_mappings(request_type, transport: str = "grpc"): client = DomainMappingsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -519,10 +518,6 @@ def test_list_domain_mappings( assert response.next_page_token == "next_page_token_value" -def test_list_domain_mappings_from_dict(): - test_list_domain_mappings(request_type=dict) - - def test_list_domain_mappings_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. @@ -636,8 +631,10 @@ async def test_list_domain_mappings_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_domain_mappings_pager(): - client = DomainMappingsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_domain_mappings_pager(transport_name: str = "grpc"): + client = DomainMappingsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -682,8 +679,10 @@ def test_list_domain_mappings_pager(): assert all(isinstance(i, domain_mapping.DomainMapping) for i in results) -def test_list_domain_mappings_pages(): - client = DomainMappingsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_domain_mappings_pages(transport_name: str = "grpc"): + client = DomainMappingsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -806,9 +805,8 @@ async def test_list_domain_mappings_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_domain_mapping( - transport: str = "grpc", request_type=appengine.GetDomainMappingRequest -): +@pytest.mark.parametrize("request_type", [appengine.GetDomainMappingRequest, dict,]) +def test_get_domain_mapping(request_type, transport: str = "grpc"): client = DomainMappingsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -838,10 +836,6 @@ def test_get_domain_mapping( assert response.id == "id_value" -def test_get_domain_mapping_from_dict(): - test_get_domain_mapping(request_type=dict) - - def test_get_domain_mapping_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. @@ -954,9 +948,8 @@ async def test_get_domain_mapping_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_domain_mapping( - transport: str = "grpc", request_type=appengine.CreateDomainMappingRequest -): +@pytest.mark.parametrize("request_type", [appengine.CreateDomainMappingRequest, dict,]) +def test_create_domain_mapping(request_type, transport: str = "grpc"): client = DomainMappingsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -982,10 +975,6 @@ def test_create_domain_mapping( assert isinstance(response, future.Future) -def test_create_domain_mapping_from_dict(): - test_create_domain_mapping(request_type=dict) - - def test_create_domain_mapping_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. @@ -1096,9 +1085,8 @@ async def test_create_domain_mapping_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_domain_mapping( - transport: str = "grpc", request_type=appengine.UpdateDomainMappingRequest -): +@pytest.mark.parametrize("request_type", [appengine.UpdateDomainMappingRequest, dict,]) +def test_update_domain_mapping(request_type, transport: str = "grpc"): client = DomainMappingsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1124,10 +1112,6 @@ def test_update_domain_mapping( assert isinstance(response, future.Future) -def test_update_domain_mapping_from_dict(): - test_update_domain_mapping(request_type=dict) - - def test_update_domain_mapping_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. @@ -1238,9 +1222,8 @@ async def test_update_domain_mapping_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_domain_mapping( - transport: str = "grpc", request_type=appengine.DeleteDomainMappingRequest -): +@pytest.mark.parametrize("request_type", [appengine.DeleteDomainMappingRequest, dict,]) +def test_delete_domain_mapping(request_type, transport: str = "grpc"): client = DomainMappingsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1266,10 +1249,6 @@ def test_delete_domain_mapping( assert isinstance(response, future.Future) -def test_delete_domain_mapping_from_dict(): - test_delete_domain_mapping(request_type=dict) - - def test_delete_domain_mapping_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. @@ -1921,7 +1900,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py index a05bec587052..ceab4ed1d9b9 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py @@ -231,20 +231,20 @@ def test_firewall_client_client_options(client_class, transport_class, transport # 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, @@ -301,7 +301,7 @@ def test_firewall_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 @@ -392,7 +392,7 @@ def test_firewall_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, @@ -419,7 +419,7 @@ def test_firewall_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", @@ -450,9 +450,8 @@ def test_firewall_client_client_options_from_dict(): ) -def test_list_ingress_rules( - transport: str = "grpc", request_type=appengine.ListIngressRulesRequest -): +@pytest.mark.parametrize("request_type", [appengine.ListIngressRulesRequest, dict,]) +def test_list_ingress_rules(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -481,10 +480,6 @@ def test_list_ingress_rules( assert response.next_page_token == "next_page_token_value" -def test_list_ingress_rules_from_dict(): - test_list_ingress_rules(request_type=dict) - - def test_list_ingress_rules_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. @@ -594,8 +589,10 @@ async def test_list_ingress_rules_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_ingress_rules_pager(): - client = FirewallClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_ingress_rules_pager(transport_name: str = "grpc"): + client = FirewallClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -636,8 +633,10 @@ def test_list_ingress_rules_pager(): assert all(isinstance(i, firewall.FirewallRule) for i in results) -def test_list_ingress_rules_pages(): - client = FirewallClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_ingress_rules_pages(transport_name: str = "grpc"): + client = FirewallClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -748,9 +747,10 @@ async def test_list_ingress_rules_async_pages(): assert page_.raw_page.next_page_token == token -def test_batch_update_ingress_rules( - transport: str = "grpc", request_type=appengine.BatchUpdateIngressRulesRequest -): +@pytest.mark.parametrize( + "request_type", [appengine.BatchUpdateIngressRulesRequest, dict,] +) +def test_batch_update_ingress_rules(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -776,10 +776,6 @@ def test_batch_update_ingress_rules( assert isinstance(response, appengine.BatchUpdateIngressRulesResponse) -def test_batch_update_ingress_rules_from_dict(): - test_batch_update_ingress_rules(request_type=dict) - - def test_batch_update_ingress_rules_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. @@ -889,9 +885,8 @@ async def test_batch_update_ingress_rules_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_ingress_rule( - transport: str = "grpc", request_type=appengine.CreateIngressRuleRequest -): +@pytest.mark.parametrize("request_type", [appengine.CreateIngressRuleRequest, dict,]) +def test_create_ingress_rule(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -926,10 +921,6 @@ def test_create_ingress_rule( assert response.description == "description_value" -def test_create_ingress_rule_from_dict(): - test_create_ingress_rule(request_type=dict) - - def test_create_ingress_rule_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. @@ -1047,9 +1038,8 @@ async def test_create_ingress_rule_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_ingress_rule( - transport: str = "grpc", request_type=appengine.GetIngressRuleRequest -): +@pytest.mark.parametrize("request_type", [appengine.GetIngressRuleRequest, dict,]) +def test_get_ingress_rule(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1082,10 +1072,6 @@ def test_get_ingress_rule( assert response.description == "description_value" -def test_get_ingress_rule_from_dict(): - test_get_ingress_rule(request_type=dict) - - def test_get_ingress_rule_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. @@ -1195,9 +1181,8 @@ async def test_get_ingress_rule_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_update_ingress_rule( - transport: str = "grpc", request_type=appengine.UpdateIngressRuleRequest -): +@pytest.mark.parametrize("request_type", [appengine.UpdateIngressRuleRequest, dict,]) +def test_update_ingress_rule(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1232,10 +1217,6 @@ def test_update_ingress_rule( assert response.description == "description_value" -def test_update_ingress_rule_from_dict(): - test_update_ingress_rule(request_type=dict) - - def test_update_ingress_rule_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. @@ -1353,9 +1334,8 @@ async def test_update_ingress_rule_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_ingress_rule( - transport: str = "grpc", request_type=appengine.DeleteIngressRuleRequest -): +@pytest.mark.parametrize("request_type", [appengine.DeleteIngressRuleRequest, dict,]) +def test_delete_ingress_rule(request_type, transport: str = "grpc"): client = FirewallClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1381,10 +1361,6 @@ def test_delete_ingress_rule( assert response is None -def test_delete_ingress_rule_from_dict(): - test_delete_ingress_rule(request_type=dict) - - def test_delete_ingress_rule_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. @@ -1983,7 +1959,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py index 75d66d2b12a9..54ec79d0102d 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py @@ -240,20 +240,20 @@ def test_instances_client_client_options(client_class, transport_class, transpor # 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, @@ -310,7 +310,7 @@ def test_instances_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 @@ -405,7 +405,7 @@ def test_instances_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, @@ -436,7 +436,7 @@ def test_instances_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", @@ -467,9 +467,8 @@ def test_instances_client_client_options_from_dict(): ) -def test_list_instances( - transport: str = "grpc", request_type=appengine.ListInstancesRequest -): +@pytest.mark.parametrize("request_type", [appengine.ListInstancesRequest, dict,]) +def test_list_instances(request_type, transport: str = "grpc"): client = InstancesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -496,10 +495,6 @@ def test_list_instances( assert response.next_page_token == "next_page_token_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. @@ -601,8 +596,10 @@ async def test_list_instances_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_instances_pager(): - client = InstancesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pager(transport_name: str = "grpc"): + client = InstancesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -639,8 +636,10 @@ def test_list_instances_pager(): assert all(isinstance(i, instance.Instance) for i in results) -def test_list_instances_pages(): - client = InstancesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pages(transport_name: str = "grpc"): + client = InstancesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -739,9 +738,8 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=appengine.GetInstanceRequest -): +@pytest.mark.parametrize("request_type", [appengine.GetInstanceRequest, dict,]) +def test_get_instance(request_type, transport: str = "grpc"): client = InstancesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -798,10 +796,6 @@ def test_get_instance( assert response.vm_liveness == instance.Instance.Liveness.LivenessState.UNKNOWN -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. @@ -933,9 +927,8 @@ async def test_get_instance_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_instance( - transport: str = "grpc", request_type=appengine.DeleteInstanceRequest -): +@pytest.mark.parametrize("request_type", [appengine.DeleteInstanceRequest, dict,]) +def test_delete_instance(request_type, transport: str = "grpc"): client = InstancesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -959,10 +952,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. @@ -1063,9 +1052,8 @@ async def test_delete_instance_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_debug_instance( - transport: str = "grpc", request_type=appengine.DebugInstanceRequest -): +@pytest.mark.parametrize("request_type", [appengine.DebugInstanceRequest, dict,]) +def test_debug_instance(request_type, transport: str = "grpc"): client = InstancesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1089,10 +1077,6 @@ def test_debug_instance( assert isinstance(response, future.Future) -def test_debug_instance_from_dict(): - test_debug_instance(request_type=dict) - - def test_debug_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. @@ -1742,7 +1726,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py index 811d07f536c9..4d8cb2c70088 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py @@ -237,20 +237,20 @@ def test_services_client_client_options(client_class, transport_class, transport # 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, @@ -307,7 +307,7 @@ def test_services_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 @@ -398,7 +398,7 @@ def test_services_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, @@ -425,7 +425,7 @@ def test_services_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", @@ -456,9 +456,8 @@ def test_services_client_client_options_from_dict(): ) -def test_list_services( - transport: str = "grpc", request_type=appengine.ListServicesRequest -): +@pytest.mark.parametrize("request_type", [appengine.ListServicesRequest, dict,]) +def test_list_services(request_type, transport: str = "grpc"): client = ServicesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -485,10 +484,6 @@ def test_list_services( assert response.next_page_token == "next_page_token_value" -def test_list_services_from_dict(): - test_list_services(request_type=dict) - - def test_list_services_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. @@ -590,8 +585,10 @@ async def test_list_services_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_services_pager(): - client = ServicesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pager(transport_name: str = "grpc"): + client = ServicesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -624,8 +621,10 @@ def test_list_services_pager(): assert all(isinstance(i, service.Service) for i in results) -def test_list_services_pages(): - client = ServicesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pages(transport_name: str = "grpc"): + client = ServicesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -712,7 +711,8 @@ async def test_list_services_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_service(transport: str = "grpc", request_type=appengine.GetServiceRequest): +@pytest.mark.parametrize("request_type", [appengine.GetServiceRequest, dict,]) +def test_get_service(request_type, transport: str = "grpc"): client = ServicesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -738,10 +738,6 @@ def test_get_service(transport: str = "grpc", request_type=appengine.GetServiceR assert response.id == "id_value" -def test_get_service_from_dict(): - test_get_service(request_type=dict) - - def test_get_service_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. @@ -842,9 +838,8 @@ async def test_get_service_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_update_service( - transport: str = "grpc", request_type=appengine.UpdateServiceRequest -): +@pytest.mark.parametrize("request_type", [appengine.UpdateServiceRequest, dict,]) +def test_update_service(request_type, transport: str = "grpc"): client = ServicesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -868,10 +863,6 @@ def test_update_service( assert isinstance(response, future.Future) -def test_update_service_from_dict(): - test_update_service(request_type=dict) - - def test_update_service_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. @@ -972,9 +963,8 @@ async def test_update_service_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_service( - transport: str = "grpc", request_type=appengine.DeleteServiceRequest -): +@pytest.mark.parametrize("request_type", [appengine.DeleteServiceRequest, dict,]) +def test_delete_service(request_type, transport: str = "grpc"): client = ServicesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -998,10 +988,6 @@ def test_delete_service( assert isinstance(response, future.Future) -def test_delete_service_from_dict(): - test_delete_service(request_type=dict) - - def test_delete_service_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. @@ -1625,7 +1611,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( diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py index ef9622d168f7..047ce45539f5 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py @@ -240,20 +240,20 @@ def test_versions_client_client_options(client_class, transport_class, transport # 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, @@ -310,7 +310,7 @@ def test_versions_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 @@ -401,7 +401,7 @@ def test_versions_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, @@ -428,7 +428,7 @@ def test_versions_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", @@ -459,9 +459,8 @@ def test_versions_client_client_options_from_dict(): ) -def test_list_versions( - transport: str = "grpc", request_type=appengine.ListVersionsRequest -): +@pytest.mark.parametrize("request_type", [appengine.ListVersionsRequest, dict,]) +def test_list_versions(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -488,10 +487,6 @@ def test_list_versions( assert response.next_page_token == "next_page_token_value" -def test_list_versions_from_dict(): - test_list_versions(request_type=dict) - - def test_list_versions_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. @@ -593,8 +588,10 @@ async def test_list_versions_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_versions_pager(): - client = VersionsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_versions_pager(transport_name: str = "grpc"): + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: @@ -627,8 +624,10 @@ def test_list_versions_pager(): assert all(isinstance(i, version.Version) for i in results) -def test_list_versions_pages(): - client = VersionsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_versions_pages(transport_name: str = "grpc"): + client = VersionsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_versions), "__call__") as call: @@ -715,7 +714,8 @@ async def test_list_versions_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_version(transport: str = "grpc", request_type=appengine.GetVersionRequest): +@pytest.mark.parametrize("request_type", [appengine.GetVersionRequest, dict,]) +def test_get_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -781,10 +781,6 @@ def test_get_version(transport: str = "grpc", request_type=appengine.GetVersionR assert response.version_url == "version_url_value" -def test_get_version_from_dict(): - test_get_version(request_type=dict) - - def test_get_version_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. @@ -922,9 +918,8 @@ async def test_get_version_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_version( - transport: str = "grpc", request_type=appengine.CreateVersionRequest -): +@pytest.mark.parametrize("request_type", [appengine.CreateVersionRequest, dict,]) +def test_create_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -948,10 +943,6 @@ def test_create_version( assert isinstance(response, future.Future) -def test_create_version_from_dict(): - test_create_version(request_type=dict) - - def test_create_version_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. @@ -1052,9 +1043,8 @@ async def test_create_version_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_version( - transport: str = "grpc", request_type=appengine.UpdateVersionRequest -): +@pytest.mark.parametrize("request_type", [appengine.UpdateVersionRequest, dict,]) +def test_update_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1078,10 +1068,6 @@ def test_update_version( assert isinstance(response, future.Future) -def test_update_version_from_dict(): - test_update_version(request_type=dict) - - def test_update_version_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. @@ -1182,9 +1168,8 @@ async def test_update_version_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_version( - transport: str = "grpc", request_type=appengine.DeleteVersionRequest -): +@pytest.mark.parametrize("request_type", [appengine.DeleteVersionRequest, dict,]) +def test_delete_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1208,10 +1193,6 @@ def test_delete_version( assert isinstance(response, future.Future) -def test_delete_version_from_dict(): - test_delete_version(request_type=dict) - - def test_delete_version_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. @@ -1836,7 +1817,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(