diff --git a/google/cloud/servicecontrol_v1/services/quota_controller/transports/base.py b/google/cloud/servicecontrol_v1/services/quota_controller/transports/base.py index f4a8645..8099043 100644 --- a/google/cloud/servicecontrol_v1/services/quota_controller/transports/base.py +++ b/google/cloud/servicecontrol_v1/services/quota_controller/transports/base.py @@ -104,7 +104,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/google/cloud/servicecontrol_v1/services/service_controller/transports/base.py b/google/cloud/servicecontrol_v1/services/service_controller/transports/base.py index d90451c..bb78aa3 100644 --- a/google/cloud/servicecontrol_v1/services/service_controller/transports/base.py +++ b/google/cloud/servicecontrol_v1/services/service_controller/transports/base.py @@ -104,7 +104,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/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py b/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py index 3022024..28f3dc3 100644 --- a/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py +++ b/tests/unit/gapic/servicecontrol_v1/test_quota_controller.py @@ -254,20 +254,20 @@ def test_quota_controller_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, @@ -336,7 +336,7 @@ def test_quota_controller_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 @@ -431,7 +431,7 @@ def test_quota_controller_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, @@ -462,7 +462,7 @@ def test_quota_controller_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", @@ -495,9 +495,8 @@ def test_quota_controller_client_client_options_from_dict(): ) -def test_allocate_quota( - transport: str = "grpc", request_type=quota_controller.AllocateQuotaRequest -): +@pytest.mark.parametrize("request_type", [quota_controller.AllocateQuotaRequest, dict,]) +def test_allocate_quota(request_type, transport: str = "grpc"): client = QuotaControllerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -526,10 +525,6 @@ def test_allocate_quota( assert response.service_config_id == "service_config_id_value" -def test_allocate_quota_from_dict(): - test_allocate_quota(request_type=dict) - - def test_allocate_quota_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. @@ -1084,7 +1079,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/tests/unit/gapic/servicecontrol_v1/test_service_controller.py b/tests/unit/gapic/servicecontrol_v1/test_service_controller.py index 4b068e8..55e291e 100644 --- a/tests/unit/gapic/servicecontrol_v1/test_service_controller.py +++ b/tests/unit/gapic/servicecontrol_v1/test_service_controller.py @@ -262,20 +262,20 @@ def test_service_controller_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, @@ -344,7 +344,7 @@ def test_service_controller_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_service_controller_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, @@ -470,7 +470,7 @@ def test_service_controller_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", @@ -503,7 +503,8 @@ def test_service_controller_client_client_options_from_dict(): ) -def test_check(transport: str = "grpc", request_type=service_controller.CheckRequest): +@pytest.mark.parametrize("request_type", [service_controller.CheckRequest, dict,]) +def test_check(request_type, transport: str = "grpc"): client = ServiceControllerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -534,10 +535,6 @@ def test_check(transport: str = "grpc", request_type=service_controller.CheckReq assert response.service_rollout_id == "service_rollout_id_value" -def test_check_from_dict(): - test_check(request_type=dict) - - def test_check_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,7 +591,8 @@ async def test_check_async_from_dict(): await test_check_async(request_type=dict) -def test_report(transport: str = "grpc", request_type=service_controller.ReportRequest): +@pytest.mark.parametrize("request_type", [service_controller.ReportRequest, dict,]) +def test_report(request_type, transport: str = "grpc"): client = ServiceControllerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -623,10 +621,6 @@ def test_report(transport: str = "grpc", request_type=service_controller.ReportR assert response.service_rollout_id == "service_rollout_id_value" -def test_report_from_dict(): - test_report(request_type=dict) - - def test_report_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. @@ -1184,7 +1178,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(