diff --git a/google/cloud/dialogflow_v2/services/agents/transports/base.py b/google/cloud/dialogflow_v2/services/agents/transports/base.py index 3438f6fda..e7727b244 100644 --- a/google/cloud/dialogflow_v2/services/agents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/agents/transports/base.py @@ -109,7 +109,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/dialogflow_v2/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2/services/answer_records/transports/base.py index 36b297434..514a003e3 100644 --- a/google/cloud/dialogflow_v2/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2/services/answer_records/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/google/cloud/dialogflow_v2/services/contexts/transports/base.py b/google/cloud/dialogflow_v2/services/contexts/transports/base.py index f8f6bbee6..c2f65b08e 100644 --- a/google/cloud/dialogflow_v2/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2/services/contexts/transports/base.py @@ -106,7 +106,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/dialogflow_v2/services/conversation_profiles/transports/base.py b/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py index 94757a92c..f4d8b24e8 100644 --- a/google/cloud/dialogflow_v2/services/conversation_profiles/transports/base.py +++ b/google/cloud/dialogflow_v2/services/conversation_profiles/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/google/cloud/dialogflow_v2/services/conversations/transports/base.py b/google/cloud/dialogflow_v2/services/conversations/transports/base.py index 4d72750f6..03f7bcee4 100644 --- a/google/cloud/dialogflow_v2/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2/services/conversations/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/google/cloud/dialogflow_v2/services/documents/transports/base.py b/google/cloud/dialogflow_v2/services/documents/transports/base.py index c3f70ac35..3c6acf37e 100644 --- a/google/cloud/dialogflow_v2/services/documents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/documents/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/google/cloud/dialogflow_v2/services/entity_types/transports/base.py b/google/cloud/dialogflow_v2/services/entity_types/transports/base.py index 6795abe9f..51de4497c 100644 --- a/google/cloud/dialogflow_v2/services/entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2/services/entity_types/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/google/cloud/dialogflow_v2/services/environments/transports/base.py b/google/cloud/dialogflow_v2/services/environments/transports/base.py index cf3fd7fe4..da41534fa 100644 --- a/google/cloud/dialogflow_v2/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/environments/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/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py index b4e627411..7ab589d60 100644 --- a/google/cloud/dialogflow_v2/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2/services/fulfillments/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/google/cloud/dialogflow_v2/services/intents/transports/base.py b/google/cloud/dialogflow_v2/services/intents/transports/base.py index b9c2be736..ef9862467 100644 --- a/google/cloud/dialogflow_v2/services/intents/transports/base.py +++ b/google/cloud/dialogflow_v2/services/intents/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/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py index 05e811e6b..a5efd1540 100644 --- a/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2/services/knowledge_bases/transports/base.py @@ -106,7 +106,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/dialogflow_v2/services/participants/transports/base.py b/google/cloud/dialogflow_v2/services/participants/transports/base.py index da5f6cec0..f5707b3b4 100644 --- a/google/cloud/dialogflow_v2/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2/services/participants/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/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py index c6371b950..431634dde 100644 --- a/google/cloud/dialogflow_v2/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2/services/session_entity_types/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/google/cloud/dialogflow_v2/services/sessions/transports/base.py b/google/cloud/dialogflow_v2/services/sessions/transports/base.py index 51a759243..f9ac3926f 100644 --- a/google/cloud/dialogflow_v2/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/sessions/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/google/cloud/dialogflow_v2/services/versions/transports/base.py b/google/cloud/dialogflow_v2/services/versions/transports/base.py index bb2a24d9b..032c583c2 100644 --- a/google/cloud/dialogflow_v2/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2/services/versions/transports/base.py @@ -106,7 +106,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/dialogflow_v2beta1/services/agents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py index 0435903ca..5239c1050 100644 --- a/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/agents/transports/base.py @@ -109,7 +109,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/dialogflow_v2beta1/services/answer_records/transports/base.py b/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py index 1f05716c4..e6d672be3 100644 --- a/google/cloud/dialogflow_v2beta1/services/answer_records/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/answer_records/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/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py index 6e231f595..000467d5a 100644 --- a/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/contexts/transports/base.py @@ -106,7 +106,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/dialogflow_v2beta1/services/conversation_profiles/transports/base.py b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py index 8beb05077..2baa96bb6 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversation_profiles/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/conversation_profiles/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/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py b/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py index 608489252..772f62656 100644 --- a/google/cloud/dialogflow_v2beta1/services/conversations/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/conversations/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/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py index 8ed597481..9081ec786 100644 --- a/google/cloud/dialogflow_v2beta1/services/documents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/documents/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/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py b/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py index 5aef232aa..49fff8629 100644 --- a/google/cloud/dialogflow_v2beta1/services/entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/entity_types/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/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py index 8fcbd2e06..c70b2fb6e 100644 --- a/google/cloud/dialogflow_v2beta1/services/environments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/environments/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/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py b/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py index 1a44230bc..40d6c6f17 100644 --- a/google/cloud/dialogflow_v2beta1/services/fulfillments/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/fulfillments/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/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py b/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py index eb785d2c1..7e8a22366 100644 --- a/google/cloud/dialogflow_v2beta1/services/intents/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/intents/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/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py index bfae48e8f..c714b03dc 100644 --- a/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/knowledge_bases/transports/base.py @@ -106,7 +106,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/dialogflow_v2beta1/services/participants/transports/base.py b/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py index 3ad6eccbd..dc19b588a 100644 --- a/google/cloud/dialogflow_v2beta1/services/participants/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/participants/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/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py b/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py index d2afdb66c..132f54ba1 100644 --- a/google/cloud/dialogflow_v2beta1/services/session_entity_types/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/session_entity_types/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/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py index 110df02f0..44b487807 100644 --- a/google/cloud/dialogflow_v2beta1/services/sessions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/sessions/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/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py index 97b2c1c0c..a43820974 100644 --- a/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py +++ b/google/cloud/dialogflow_v2beta1/services/versions/transports/base.py @@ -106,7 +106,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/dialogflow_v2/test_agents.py b/tests/unit/gapic/dialogflow_v2/test_agents.py index 4c262a183..1d6cc9c16 100644 --- a/tests/unit/gapic/dialogflow_v2/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2/test_agents.py @@ -232,20 +232,20 @@ def test_agents_client_client_options(client_class, transport_class, transport_n # 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, @@ -300,7 +300,7 @@ def test_agents_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 @@ -391,7 +391,7 @@ def test_agents_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, @@ -418,7 +418,7 @@ def test_agents_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", @@ -449,7 +449,8 @@ def test_agents_client_client_options_from_dict(): ) -def test_get_agent(transport: str = "grpc", request_type=agent.GetAgentRequest): +@pytest.mark.parametrize("request_type", [agent.GetAgentRequest, dict,]) +def test_get_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -500,10 +501,6 @@ def test_get_agent(transport: str = "grpc", request_type=agent.GetAgentRequest): assert response.tier == agent.Agent.Tier.TIER_STANDARD -def test_get_agent_from_dict(): - test_get_agent(request_type=dict) - - def test_get_agent_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. @@ -695,7 +692,8 @@ async def test_get_agent_flattened_error_async(): ) -def test_set_agent(transport: str = "grpc", request_type=gcd_agent.SetAgentRequest): +@pytest.mark.parametrize("request_type", [gcd_agent.SetAgentRequest, dict,]) +def test_set_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -746,10 +744,6 @@ def test_set_agent(transport: str = "grpc", request_type=gcd_agent.SetAgentReque assert response.tier == gcd_agent.Agent.Tier.TIER_STANDARD -def test_set_agent_from_dict(): - test_set_agent(request_type=dict) - - def test_set_agent_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. @@ -945,7 +939,8 @@ async def test_set_agent_flattened_error_async(): ) -def test_delete_agent(transport: str = "grpc", request_type=agent.DeleteAgentRequest): +@pytest.mark.parametrize("request_type", [agent.DeleteAgentRequest, dict,]) +def test_delete_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -969,10 +964,6 @@ def test_delete_agent(transport: str = "grpc", request_type=agent.DeleteAgentReq assert response is None -def test_delete_agent_from_dict(): - test_delete_agent(request_type=dict) - - def test_delete_agent_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,7 +1126,8 @@ async def test_delete_agent_flattened_error_async(): ) -def test_search_agents(transport: str = "grpc", request_type=agent.SearchAgentsRequest): +@pytest.mark.parametrize("request_type", [agent.SearchAgentsRequest, dict,]) +def test_search_agents(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1162,10 +1154,6 @@ def test_search_agents(transport: str = "grpc", request_type=agent.SearchAgentsR assert response.next_page_token == "next_page_token_value" -def test_search_agents_from_dict(): - test_search_agents(request_type=dict) - - def test_search_agents_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. @@ -1335,8 +1323,10 @@ async def test_search_agents_flattened_error_async(): ) -def test_search_agents_pager(): - client = AgentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_agents_pager(transport_name: str = "grpc"): + client = AgentsClient( + 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.search_agents), "__call__") as call: @@ -1365,8 +1355,10 @@ def test_search_agents_pager(): assert all(isinstance(i, agent.Agent) for i in results) -def test_search_agents_pages(): - client = AgentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_agents_pages(transport_name: str = "grpc"): + client = AgentsClient( + 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.search_agents), "__call__") as call: @@ -1441,7 +1433,8 @@ async def test_search_agents_async_pages(): assert page_.raw_page.next_page_token == token -def test_train_agent(transport: str = "grpc", request_type=agent.TrainAgentRequest): +@pytest.mark.parametrize("request_type", [agent.TrainAgentRequest, dict,]) +def test_train_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1465,10 +1458,6 @@ def test_train_agent(transport: str = "grpc", request_type=agent.TrainAgentReque assert isinstance(response, future.Future) -def test_train_agent_from_dict(): - test_train_agent(request_type=dict) - - def test_train_agent_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. @@ -1637,7 +1626,8 @@ async def test_train_agent_flattened_error_async(): ) -def test_export_agent(transport: str = "grpc", request_type=agent.ExportAgentRequest): +@pytest.mark.parametrize("request_type", [agent.ExportAgentRequest, dict,]) +def test_export_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1661,10 +1651,6 @@ def test_export_agent(transport: str = "grpc", request_type=agent.ExportAgentReq assert isinstance(response, future.Future) -def test_export_agent_from_dict(): - test_export_agent(request_type=dict) - - def test_export_agent_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. @@ -1833,7 +1819,8 @@ async def test_export_agent_flattened_error_async(): ) -def test_import_agent(transport: str = "grpc", request_type=agent.ImportAgentRequest): +@pytest.mark.parametrize("request_type", [agent.ImportAgentRequest, dict,]) +def test_import_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1857,10 +1844,6 @@ def test_import_agent(transport: str = "grpc", request_type=agent.ImportAgentReq assert isinstance(response, future.Future) -def test_import_agent_from_dict(): - test_import_agent(request_type=dict) - - def test_import_agent_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. @@ -1961,7 +1944,8 @@ async def test_import_agent_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_restore_agent(transport: str = "grpc", request_type=agent.RestoreAgentRequest): +@pytest.mark.parametrize("request_type", [agent.RestoreAgentRequest, dict,]) +def test_restore_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1985,10 +1969,6 @@ def test_restore_agent(transport: str = "grpc", request_type=agent.RestoreAgentR assert isinstance(response, future.Future) -def test_restore_agent_from_dict(): - test_restore_agent(request_type=dict) - - def test_restore_agent_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. @@ -2089,9 +2069,8 @@ async def test_restore_agent_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_validation_result( - transport: str = "grpc", request_type=agent.GetValidationResultRequest -): +@pytest.mark.parametrize("request_type", [agent.GetValidationResultRequest, dict,]) +def test_get_validation_result(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2117,10 +2096,6 @@ def test_get_validation_result( assert isinstance(response, validation_result.ValidationResult) -def test_get_validation_result_from_dict(): - test_get_validation_result(request_type=dict) - - def test_get_validation_result_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. @@ -2771,7 +2746,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/dialogflow_v2/test_answer_records.py b/tests/unit/gapic/dialogflow_v2/test_answer_records.py index 1f9a031f2..ff309cea1 100644 --- a/tests/unit/gapic/dialogflow_v2/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2/test_answer_records.py @@ -250,20 +250,20 @@ def test_answer_records_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, @@ -322,7 +322,7 @@ def test_answer_records_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 @@ -417,7 +417,7 @@ def test_answer_records_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, @@ -448,7 +448,7 @@ def test_answer_records_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", @@ -481,9 +481,10 @@ def test_answer_records_client_client_options_from_dict(): ) -def test_list_answer_records( - transport: str = "grpc", request_type=answer_record.ListAnswerRecordsRequest -): +@pytest.mark.parametrize( + "request_type", [answer_record.ListAnswerRecordsRequest, dict,] +) +def test_list_answer_records(request_type, transport: str = "grpc"): client = AnswerRecordsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -512,10 +513,6 @@ def test_list_answer_records( assert response.next_page_token == "next_page_token_value" -def test_list_answer_records_from_dict(): - test_list_answer_records(request_type=dict) - - def test_list_answer_records_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. @@ -705,8 +702,10 @@ async def test_list_answer_records_flattened_error_async(): ) -def test_list_answer_records_pager(): - client = AnswerRecordsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_answer_records_pager(transport_name: str = "grpc"): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -750,8 +749,10 @@ def test_list_answer_records_pager(): assert all(isinstance(i, answer_record.AnswerRecord) for i in results) -def test_list_answer_records_pages(): - client = AnswerRecordsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_answer_records_pages(transport_name: str = "grpc"): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -871,9 +872,10 @@ async def test_list_answer_records_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_answer_record( - transport: str = "grpc", request_type=gcd_answer_record.UpdateAnswerRecordRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_answer_record.UpdateAnswerRecordRequest, dict,] +) +def test_update_answer_record(request_type, transport: str = "grpc"): client = AnswerRecordsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -905,10 +907,6 @@ def test_update_answer_record( assert response.name == "name_value" -def test_update_answer_record_from_dict(): - test_update_answer_record(request_type=dict) - - def test_update_answer_record_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. @@ -1642,7 +1640,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/dialogflow_v2/test_contexts.py b/tests/unit/gapic/dialogflow_v2/test_contexts.py index f2a087a9c..6a05225f6 100644 --- a/tests/unit/gapic/dialogflow_v2/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2/test_contexts.py @@ -232,20 +232,20 @@ def test_contexts_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, @@ -302,7 +302,7 @@ def test_contexts_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 @@ -393,7 +393,7 @@ def test_contexts_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, @@ -420,7 +420,7 @@ def test_contexts_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", @@ -451,9 +451,8 @@ def test_contexts_client_client_options_from_dict(): ) -def test_list_contexts( - transport: str = "grpc", request_type=context.ListContextsRequest -): +@pytest.mark.parametrize("request_type", [context.ListContextsRequest, dict,]) +def test_list_contexts(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -480,10 +479,6 @@ def test_list_contexts( assert response.next_page_token == "next_page_token_value" -def test_list_contexts_from_dict(): - test_list_contexts(request_type=dict) - - def test_list_contexts_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. @@ -653,8 +648,10 @@ async def test_list_contexts_flattened_error_async(): ) -def test_list_contexts_pager(): - client = ContextsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pager(transport_name: str = "grpc"): + client = ContextsClient( + 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_contexts), "__call__") as call: @@ -687,8 +684,10 @@ def test_list_contexts_pager(): assert all(isinstance(i, context.Context) for i in results) -def test_list_contexts_pages(): - client = ContextsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pages(transport_name: str = "grpc"): + client = ContextsClient( + 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_contexts), "__call__") as call: @@ -775,7 +774,8 @@ async def test_list_contexts_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_context(transport: str = "grpc", request_type=context.GetContextRequest): +@pytest.mark.parametrize("request_type", [context.GetContextRequest, dict,]) +def test_get_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -801,10 +801,6 @@ def test_get_context(transport: str = "grpc", request_type=context.GetContextReq assert response.lifespan_count == 1498 -def test_get_context_from_dict(): - test_get_context(request_type=dict) - - def test_get_context_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. @@ -971,9 +967,8 @@ async def test_get_context_flattened_error_async(): ) -def test_create_context( - transport: str = "grpc", request_type=gcd_context.CreateContextRequest -): +@pytest.mark.parametrize("request_type", [gcd_context.CreateContextRequest, dict,]) +def test_create_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -999,10 +994,6 @@ def test_create_context( assert response.lifespan_count == 1498 -def test_create_context_from_dict(): - test_create_context(request_type=dict) - - def test_create_context_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. @@ -1183,9 +1174,8 @@ async def test_create_context_flattened_error_async(): ) -def test_update_context( - transport: str = "grpc", request_type=gcd_context.UpdateContextRequest -): +@pytest.mark.parametrize("request_type", [gcd_context.UpdateContextRequest, dict,]) +def test_update_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1211,10 +1201,6 @@ def test_update_context( assert response.lifespan_count == 1498 -def test_update_context_from_dict(): - test_update_context(request_type=dict) - - def test_update_context_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. @@ -1401,9 +1387,8 @@ async def test_update_context_flattened_error_async(): ) -def test_delete_context( - transport: str = "grpc", request_type=context.DeleteContextRequest -): +@pytest.mark.parametrize("request_type", [context.DeleteContextRequest, dict,]) +def test_delete_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1427,10 +1412,6 @@ def test_delete_context( assert response is None -def test_delete_context_from_dict(): - test_delete_context(request_type=dict) - - def test_delete_context_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. @@ -1593,9 +1574,8 @@ async def test_delete_context_flattened_error_async(): ) -def test_delete_all_contexts( - transport: str = "grpc", request_type=context.DeleteAllContextsRequest -): +@pytest.mark.parametrize("request_type", [context.DeleteAllContextsRequest, dict,]) +def test_delete_all_contexts(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1621,10 +1601,6 @@ def test_delete_all_contexts( assert response is None -def test_delete_all_contexts_from_dict(): - test_delete_all_contexts(request_type=dict) - - def test_delete_all_contexts_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. @@ -2313,7 +2289,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/dialogflow_v2/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py index a7f488276..4960e5a30 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversation_profiles.py @@ -261,20 +261,20 @@ def test_conversation_profiles_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, @@ -343,7 +343,7 @@ def test_conversation_profiles_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 @@ -442,7 +442,7 @@ def test_conversation_profiles_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, @@ -477,7 +477,7 @@ def test_conversation_profiles_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", @@ -510,10 +510,10 @@ def test_conversation_profiles_client_client_options_from_dict(): ) -def test_list_conversation_profiles( - transport: str = "grpc", - request_type=conversation_profile.ListConversationProfilesRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.ListConversationProfilesRequest, dict,] +) +def test_list_conversation_profiles(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -542,10 +542,6 @@ def test_list_conversation_profiles( assert response.next_page_token == "next_page_token_value" -def test_list_conversation_profiles_from_dict(): - test_list_conversation_profiles(request_type=dict) - - def test_list_conversation_profiles_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. @@ -744,9 +740,9 @@ async def test_list_conversation_profiles_flattened_error_async(): ) -def test_list_conversation_profiles_pager(): +def test_list_conversation_profiles_pager(transport_name: str = "grpc"): client = ConversationProfilesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -794,9 +790,9 @@ def test_list_conversation_profiles_pager(): ) -def test_list_conversation_profiles_pages(): +def test_list_conversation_profiles_pages(transport_name: str = "grpc"): client = ConversationProfilesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -926,10 +922,10 @@ async def test_list_conversation_profiles_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_conversation_profile( - transport: str = "grpc", - request_type=conversation_profile.GetConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.GetConversationProfileRequest, dict,] +) +def test_get_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -966,10 +962,6 @@ def test_get_conversation_profile( assert response.security_settings == "security_settings_value" -def test_get_conversation_profile_from_dict(): - test_get_conversation_profile(request_type=dict) - - def test_get_conversation_profile_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. @@ -1174,10 +1166,10 @@ async def test_get_conversation_profile_flattened_error_async(): ) -def test_create_conversation_profile( - transport: str = "grpc", - request_type=gcd_conversation_profile.CreateConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation_profile.CreateConversationProfileRequest, dict,] +) +def test_create_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1214,10 +1206,6 @@ def test_create_conversation_profile( assert response.security_settings == "security_settings_value" -def test_create_conversation_profile_from_dict(): - test_create_conversation_profile(request_type=dict) - - def test_create_conversation_profile_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. @@ -1446,10 +1434,10 @@ async def test_create_conversation_profile_flattened_error_async(): ) -def test_update_conversation_profile( - transport: str = "grpc", - request_type=gcd_conversation_profile.UpdateConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation_profile.UpdateConversationProfileRequest, dict,] +) +def test_update_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1486,10 +1474,6 @@ def test_update_conversation_profile( assert response.security_settings == "security_settings_value" -def test_update_conversation_profile_from_dict(): - test_update_conversation_profile(request_type=dict) - - def test_update_conversation_profile_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. @@ -1724,10 +1708,10 @@ async def test_update_conversation_profile_flattened_error_async(): ) -def test_delete_conversation_profile( - transport: str = "grpc", - request_type=conversation_profile.DeleteConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.DeleteConversationProfileRequest, dict,] +) +def test_delete_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1753,10 +1737,6 @@ def test_delete_conversation_profile( assert response is None -def test_delete_conversation_profile_from_dict(): - test_delete_conversation_profile(request_type=dict) - - def test_delete_conversation_profile_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. @@ -2594,7 +2574,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/dialogflow_v2/test_conversations.py b/tests/unit/gapic/dialogflow_v2/test_conversations.py index d8aaef6df..48d6ee963 100644 --- a/tests/unit/gapic/dialogflow_v2/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2/test_conversations.py @@ -249,20 +249,20 @@ def test_conversations_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, @@ -321,7 +321,7 @@ def test_conversations_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 @@ -416,7 +416,7 @@ def test_conversations_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, @@ -447,7 +447,7 @@ def test_conversations_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", @@ -480,9 +480,10 @@ def test_conversations_client_client_options_from_dict(): ) -def test_create_conversation( - transport: str = "grpc", request_type=gcd_conversation.CreateConversationRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation.CreateConversationRequest, dict,] +) +def test_create_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -523,10 +524,6 @@ def test_create_conversation( ) -def test_create_conversation_from_dict(): - test_create_conversation(request_type=dict) - - def test_create_conversation_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. @@ -745,9 +742,8 @@ async def test_create_conversation_flattened_error_async(): ) -def test_list_conversations( - transport: str = "grpc", request_type=conversation.ListConversationsRequest -): +@pytest.mark.parametrize("request_type", [conversation.ListConversationsRequest, dict,]) +def test_list_conversations(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -776,10 +772,6 @@ def test_list_conversations( assert response.next_page_token == "next_page_token_value" -def test_list_conversations_from_dict(): - test_list_conversations(request_type=dict) - - def test_list_conversations_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. @@ -969,8 +961,10 @@ async def test_list_conversations_flattened_error_async(): ) -def test_list_conversations_pager(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_conversations_pager(transport_name: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1014,8 +1008,10 @@ def test_list_conversations_pager(): assert all(isinstance(i, conversation.Conversation) for i in results) -def test_list_conversations_pages(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_conversations_pages(transport_name: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1135,9 +1131,8 @@ async def test_list_conversations_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_conversation( - transport: str = "grpc", request_type=conversation.GetConversationRequest -): +@pytest.mark.parametrize("request_type", [conversation.GetConversationRequest, dict,]) +def test_get_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1175,10 +1170,6 @@ def test_get_conversation( ) -def test_get_conversation_from_dict(): - test_get_conversation(request_type=dict) - - def test_get_conversation_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. @@ -1367,9 +1358,10 @@ async def test_get_conversation_flattened_error_async(): ) -def test_complete_conversation( - transport: str = "grpc", request_type=conversation.CompleteConversationRequest -): +@pytest.mark.parametrize( + "request_type", [conversation.CompleteConversationRequest, dict,] +) +def test_complete_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1409,10 +1401,6 @@ def test_complete_conversation( ) -def test_complete_conversation_from_dict(): - test_complete_conversation(request_type=dict) - - def test_complete_conversation_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. @@ -1614,9 +1602,8 @@ async def test_complete_conversation_flattened_error_async(): ) -def test_list_messages( - transport: str = "grpc", request_type=conversation.ListMessagesRequest -): +@pytest.mark.parametrize("request_type", [conversation.ListMessagesRequest, dict,]) +def test_list_messages(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1643,10 +1630,6 @@ def test_list_messages( assert response.next_page_token == "next_page_token_value" -def test_list_messages_from_dict(): - test_list_messages(request_type=dict) - - def test_list_messages_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. @@ -1822,8 +1805,10 @@ async def test_list_messages_flattened_error_async(): ) -def test_list_messages_pager(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_messages_pager(transport_name: str = "grpc"): + client = ConversationsClient( + 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_messages), "__call__") as call: @@ -1860,8 +1845,10 @@ def test_list_messages_pager(): assert all(isinstance(i, participant.Message) for i in results) -def test_list_messages_pages(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_messages_pages(transport_name: str = "grpc"): + client = ConversationsClient( + 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_messages), "__call__") as call: @@ -2534,7 +2521,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/dialogflow_v2/test_documents.py b/tests/unit/gapic/dialogflow_v2/test_documents.py index d32bdafa0..a29db8f78 100644 --- a/tests/unit/gapic/dialogflow_v2/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2/test_documents.py @@ -243,20 +243,20 @@ def test_documents_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, @@ -313,7 +313,7 @@ def test_documents_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 @@ -408,7 +408,7 @@ def test_documents_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, @@ -439,7 +439,7 @@ def test_documents_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", @@ -470,9 +470,8 @@ def test_documents_client_client_options_from_dict(): ) -def test_list_documents( - transport: str = "grpc", request_type=document.ListDocumentsRequest -): +@pytest.mark.parametrize("request_type", [document.ListDocumentsRequest, dict,]) +def test_list_documents(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -499,10 +498,6 @@ def test_list_documents( assert response.next_page_token == "next_page_token_value" -def test_list_documents_from_dict(): - test_list_documents(request_type=dict) - - def test_list_documents_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. @@ -672,8 +667,10 @@ async def test_list_documents_flattened_error_async(): ) -def test_list_documents_pager(): - client = DocumentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_documents_pager(transport_name: str = "grpc"): + client = DocumentsClient( + 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_documents), "__call__") as call: @@ -710,8 +707,10 @@ def test_list_documents_pager(): assert all(isinstance(i, document.Document) for i in results) -def test_list_documents_pages(): - client = DocumentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_documents_pages(transport_name: str = "grpc"): + client = DocumentsClient( + 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_documents), "__call__") as call: @@ -810,9 +809,8 @@ async def test_list_documents_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_document( - transport: str = "grpc", request_type=document.GetDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.GetDocumentRequest, dict,]) +def test_get_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -848,10 +846,6 @@ def test_get_document( assert response.enable_auto_reload is True -def test_get_document_from_dict(): - test_get_document(request_type=dict) - - def test_get_document_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. @@ -1027,9 +1021,8 @@ async def test_get_document_flattened_error_async(): ) -def test_create_document( - transport: str = "grpc", request_type=gcd_document.CreateDocumentRequest -): +@pytest.mark.parametrize("request_type", [gcd_document.CreateDocumentRequest, dict,]) +def test_create_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1053,10 +1046,6 @@ def test_create_document( assert isinstance(response, future.Future) -def test_create_document_from_dict(): - test_create_document(request_type=dict) - - def test_create_document_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. @@ -1239,9 +1228,8 @@ async def test_create_document_flattened_error_async(): ) -def test_delete_document( - transport: str = "grpc", request_type=document.DeleteDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.DeleteDocumentRequest, dict,]) +def test_delete_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1265,10 +1253,6 @@ def test_delete_document( assert isinstance(response, future.Future) -def test_delete_document_from_dict(): - test_delete_document(request_type=dict) - - def test_delete_document_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. @@ -1437,9 +1421,8 @@ async def test_delete_document_flattened_error_async(): ) -def test_update_document( - transport: str = "grpc", request_type=gcd_document.UpdateDocumentRequest -): +@pytest.mark.parametrize("request_type", [gcd_document.UpdateDocumentRequest, dict,]) +def test_update_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1463,10 +1446,6 @@ def test_update_document( assert isinstance(response, future.Future) -def test_update_document_from_dict(): - test_update_document(request_type=dict) - - def test_update_document_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. @@ -1655,9 +1634,8 @@ async def test_update_document_flattened_error_async(): ) -def test_reload_document( - transport: str = "grpc", request_type=document.ReloadDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.ReloadDocumentRequest, dict,]) +def test_reload_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1681,10 +1659,6 @@ def test_reload_document( assert isinstance(response, future.Future) -def test_reload_document_from_dict(): - test_reload_document(request_type=dict) - - def test_reload_document_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. @@ -1863,9 +1837,8 @@ async def test_reload_document_flattened_error_async(): ) -def test_export_document( - transport: str = "grpc", request_type=document.ExportDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.ExportDocumentRequest, dict,]) +def test_export_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1889,10 +1862,6 @@ def test_export_document( assert isinstance(response, future.Future) -def test_export_document_from_dict(): - test_export_document(request_type=dict) - - def test_export_document_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. @@ -2539,7 +2508,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/dialogflow_v2/test_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_entity_types.py index 7c6ce3960..e98525731 100644 --- a/tests/unit/gapic/dialogflow_v2/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_entity_types.py @@ -244,20 +244,20 @@ def test_entity_types_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, @@ -314,7 +314,7 @@ def test_entity_types_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 @@ -409,7 +409,7 @@ def test_entity_types_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, @@ -440,7 +440,7 @@ def test_entity_types_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", @@ -471,9 +471,8 @@ def test_entity_types_client_client_options_from_dict(): ) -def test_list_entity_types( - transport: str = "grpc", request_type=entity_type.ListEntityTypesRequest -): +@pytest.mark.parametrize("request_type", [entity_type.ListEntityTypesRequest, dict,]) +def test_list_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -502,10 +501,6 @@ def test_list_entity_types( assert response.next_page_token == "next_page_token_value" -def test_list_entity_types_from_dict(): - test_list_entity_types(request_type=dict) - - def test_list_entity_types_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. @@ -703,8 +698,10 @@ async def test_list_entity_types_flattened_error_async(): ) -def test_list_entity_types_pager(): - client = EntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pager(transport_name: str = "grpc"): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -745,8 +742,10 @@ def test_list_entity_types_pager(): assert all(isinstance(i, entity_type.EntityType) for i in results) -def test_list_entity_types_pages(): - client = EntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pages(transport_name: str = "grpc"): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -857,9 +856,8 @@ async def test_list_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_entity_type( - transport: str = "grpc", request_type=entity_type.GetEntityTypeRequest -): +@pytest.mark.parametrize("request_type", [entity_type.GetEntityTypeRequest, dict,]) +def test_get_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -897,10 +895,6 @@ def test_get_entity_type( assert response.enable_fuzzy_extraction is True -def test_get_entity_type_from_dict(): - test_get_entity_type(request_type=dict) - - def test_get_entity_type_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. @@ -1097,9 +1091,10 @@ async def test_get_entity_type_flattened_error_async(): ) -def test_create_entity_type( - transport: str = "grpc", request_type=gcd_entity_type.CreateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_entity_type.CreateEntityTypeRequest, dict,] +) +def test_create_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1139,10 +1134,6 @@ def test_create_entity_type( assert response.enable_fuzzy_extraction is True -def test_create_entity_type_from_dict(): - test_create_entity_type(request_type=dict) - - def test_create_entity_type_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. @@ -1364,9 +1355,10 @@ async def test_create_entity_type_flattened_error_async(): ) -def test_update_entity_type( - transport: str = "grpc", request_type=gcd_entity_type.UpdateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_entity_type.UpdateEntityTypeRequest, dict,] +) +def test_update_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1406,10 +1398,6 @@ def test_update_entity_type( assert response.enable_fuzzy_extraction is True -def test_update_entity_type_from_dict(): - test_update_entity_type(request_type=dict) - - def test_update_entity_type_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,9 +1613,8 @@ async def test_update_entity_type_flattened_error_async(): ) -def test_delete_entity_type( - transport: str = "grpc", request_type=entity_type.DeleteEntityTypeRequest -): +@pytest.mark.parametrize("request_type", [entity_type.DeleteEntityTypeRequest, dict,]) +def test_delete_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1653,10 +1640,6 @@ def test_delete_entity_type( assert response is None -def test_delete_entity_type_from_dict(): - test_delete_entity_type(request_type=dict) - - def test_delete_entity_type_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. @@ -1831,9 +1814,10 @@ async def test_delete_entity_type_flattened_error_async(): ) -def test_batch_update_entity_types( - transport: str = "grpc", request_type=entity_type.BatchUpdateEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchUpdateEntityTypesRequest, dict,] +) +def test_batch_update_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1859,10 +1843,6 @@ def test_batch_update_entity_types( assert isinstance(response, future.Future) -def test_batch_update_entity_types_from_dict(): - test_batch_update_entity_types(request_type=dict) - - def test_batch_update_entity_types_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. @@ -1972,9 +1952,10 @@ async def test_batch_update_entity_types_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_delete_entity_types( - transport: str = "grpc", request_type=entity_type.BatchDeleteEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchDeleteEntityTypesRequest, dict,] +) +def test_batch_delete_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2000,10 +1981,6 @@ def test_batch_delete_entity_types( assert isinstance(response, future.Future) -def test_batch_delete_entity_types_from_dict(): - test_batch_delete_entity_types(request_type=dict) - - def test_batch_delete_entity_types_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. @@ -2199,9 +2176,10 @@ async def test_batch_delete_entity_types_flattened_error_async(): ) -def test_batch_create_entities( - transport: str = "grpc", request_type=entity_type.BatchCreateEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchCreateEntitiesRequest, dict,] +) +def test_batch_create_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2227,10 +2205,6 @@ def test_batch_create_entities( assert isinstance(response, future.Future) -def test_batch_create_entities_from_dict(): - test_batch_create_entities(request_type=dict) - - def test_batch_create_entities_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. @@ -2437,9 +2411,10 @@ async def test_batch_create_entities_flattened_error_async(): ) -def test_batch_update_entities( - transport: str = "grpc", request_type=entity_type.BatchUpdateEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchUpdateEntitiesRequest, dict,] +) +def test_batch_update_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2465,10 +2440,6 @@ def test_batch_update_entities( assert isinstance(response, future.Future) -def test_batch_update_entities_from_dict(): - test_batch_update_entities(request_type=dict) - - def test_batch_update_entities_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. @@ -2675,9 +2646,10 @@ async def test_batch_update_entities_flattened_error_async(): ) -def test_batch_delete_entities( - transport: str = "grpc", request_type=entity_type.BatchDeleteEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchDeleteEntitiesRequest, dict,] +) +def test_batch_delete_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2703,10 +2675,6 @@ def test_batch_delete_entities( assert isinstance(response, future.Future) -def test_batch_delete_entities_from_dict(): - test_batch_delete_entities(request_type=dict) - - def test_batch_delete_entities_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. @@ -3460,7 +3428,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/dialogflow_v2/test_environments.py b/tests/unit/gapic/dialogflow_v2/test_environments.py index 00ceb70bc..f9f2c71a7 100644 --- a/tests/unit/gapic/dialogflow_v2/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2/test_environments.py @@ -241,20 +241,20 @@ def test_environments_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, @@ -311,7 +311,7 @@ def test_environments_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 @@ -406,7 +406,7 @@ def test_environments_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, @@ -437,7 +437,7 @@ def test_environments_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", @@ -468,9 +468,8 @@ def test_environments_client_client_options_from_dict(): ) -def test_list_environments( - transport: str = "grpc", request_type=environment.ListEnvironmentsRequest -): +@pytest.mark.parametrize("request_type", [environment.ListEnvironmentsRequest, dict,]) +def test_list_environments(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -499,10 +498,6 @@ def test_list_environments( assert response.next_page_token == "next_page_token_value" -def test_list_environments_from_dict(): - test_list_environments(request_type=dict) - - def test_list_environments_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. @@ -686,8 +681,10 @@ async def test_list_environments_flattened_error_async(): ) -def test_list_environments_pager(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_environments_pager(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -728,8 +725,10 @@ def test_list_environments_pager(): assert all(isinstance(i, environment.Environment) for i in results) -def test_list_environments_pages(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_environments_pages(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -840,9 +839,8 @@ async def test_list_environments_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_environment( - transport: str = "grpc", request_type=environment.GetEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.GetEnvironmentRequest, dict,]) +def test_get_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -875,10 +873,6 @@ def test_get_environment( assert response.state == environment.Environment.State.STOPPED -def test_get_environment_from_dict(): - test_get_environment(request_type=dict) - - def test_get_environment_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. @@ -988,9 +982,8 @@ async def test_get_environment_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_environment( - transport: str = "grpc", request_type=environment.CreateEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.CreateEnvironmentRequest, dict,]) +def test_create_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1025,10 +1018,6 @@ def test_create_environment( assert response.state == environment.Environment.State.STOPPED -def test_create_environment_from_dict(): - test_create_environment(request_type=dict) - - def test_create_environment_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. @@ -1146,9 +1135,8 @@ async def test_create_environment_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_environment( - transport: str = "grpc", request_type=environment.UpdateEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.UpdateEnvironmentRequest, dict,]) +def test_update_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1183,10 +1171,6 @@ def test_update_environment( assert response.state == environment.Environment.State.STOPPED -def test_update_environment_from_dict(): - test_update_environment(request_type=dict) - - def test_update_environment_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. @@ -1308,9 +1292,8 @@ async def test_update_environment_field_headers_async(): ] -def test_delete_environment( - transport: str = "grpc", request_type=environment.DeleteEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.DeleteEnvironmentRequest, dict,]) +def test_delete_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1336,10 +1319,6 @@ def test_delete_environment( assert response is None -def test_delete_environment_from_dict(): - test_delete_environment(request_type=dict) - - def test_delete_environment_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. @@ -1444,9 +1423,10 @@ async def test_delete_environment_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_environment_history( - transport: str = "grpc", request_type=environment.GetEnvironmentHistoryRequest -): +@pytest.mark.parametrize( + "request_type", [environment.GetEnvironmentHistoryRequest, dict,] +) +def test_get_environment_history(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1476,10 +1456,6 @@ def test_get_environment_history( assert response.next_page_token == "next_page_token_value" -def test_get_environment_history_from_dict(): - test_get_environment_history(request_type=dict) - - def test_get_environment_history_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. @@ -1593,8 +1569,10 @@ async def test_get_environment_history_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_environment_history_pager(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_get_environment_history_pager(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1637,8 +1615,10 @@ def test_get_environment_history_pager(): assert all(isinstance(i, environment.EnvironmentHistory.Entry) for i in results) -def test_get_environment_history_pages(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_get_environment_history_pages(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2315,7 +2295,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/dialogflow_v2/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2/test_fulfillments.py index 6a2360877..d8854e1a1 100644 --- a/tests/unit/gapic/dialogflow_v2/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2/test_fulfillments.py @@ -238,20 +238,20 @@ def test_fulfillments_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, @@ -308,7 +308,7 @@ def test_fulfillments_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 @@ -403,7 +403,7 @@ def test_fulfillments_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, @@ -434,7 +434,7 @@ def test_fulfillments_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", @@ -465,9 +465,8 @@ def test_fulfillments_client_client_options_from_dict(): ) -def test_get_fulfillment( - transport: str = "grpc", request_type=fulfillment.GetFulfillmentRequest -): +@pytest.mark.parametrize("request_type", [fulfillment.GetFulfillmentRequest, dict,]) +def test_get_fulfillment(request_type, transport: str = "grpc"): client = FulfillmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -501,10 +500,6 @@ def test_get_fulfillment( assert response.enabled is True -def test_get_fulfillment_from_dict(): - test_get_fulfillment(request_type=dict) - - def test_get_fulfillment_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. @@ -678,9 +673,10 @@ async def test_get_fulfillment_flattened_error_async(): ) -def test_update_fulfillment( - transport: str = "grpc", request_type=gcd_fulfillment.UpdateFulfillmentRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_fulfillment.UpdateFulfillmentRequest, dict,] +) +def test_update_fulfillment(request_type, transport: str = "grpc"): client = FulfillmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -716,10 +712,6 @@ def test_update_fulfillment( assert response.enabled is True -def test_update_fulfillment_from_dict(): - test_update_fulfillment(request_type=dict) - - def test_update_fulfillment_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. @@ -1436,7 +1428,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/dialogflow_v2/test_intents.py b/tests/unit/gapic/dialogflow_v2/test_intents.py index d5c2ac54a..61ce43c4a 100644 --- a/tests/unit/gapic/dialogflow_v2/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2/test_intents.py @@ -232,20 +232,20 @@ def test_intents_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, @@ -300,7 +300,7 @@ def test_intents_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 @@ -391,7 +391,7 @@ def test_intents_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, @@ -418,7 +418,7 @@ def test_intents_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", @@ -449,7 +449,8 @@ def test_intents_client_client_options_from_dict(): ) -def test_list_intents(transport: str = "grpc", request_type=intent.ListIntentsRequest): +@pytest.mark.parametrize("request_type", [intent.ListIntentsRequest, dict,]) +def test_list_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -476,10 +477,6 @@ def test_list_intents(transport: str = "grpc", request_type=intent.ListIntentsRe assert response.next_page_token == "next_page_token_value" -def test_list_intents_from_dict(): - test_list_intents(request_type=dict) - - def test_list_intents_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. @@ -663,8 +660,10 @@ async def test_list_intents_flattened_error_async(): ) -def test_list_intents_pager(): - client = IntentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_intents_pager(transport_name: str = "grpc"): + client = IntentsClient( + 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_intents), "__call__") as call: @@ -695,8 +694,10 @@ def test_list_intents_pager(): assert all(isinstance(i, intent.Intent) for i in results) -def test_list_intents_pages(): - client = IntentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_intents_pages(transport_name: str = "grpc"): + client = IntentsClient( + 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_intents), "__call__") as call: @@ -777,7 +778,8 @@ async def test_list_intents_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_intent(transport: str = "grpc", request_type=intent.GetIntentRequest): +@pytest.mark.parametrize("request_type", [intent.GetIntentRequest, dict,]) +def test_get_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -834,10 +836,6 @@ def test_get_intent(transport: str = "grpc", request_type=intent.GetIntentReques assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_get_intent_from_dict(): - test_get_intent(request_type=dict) - - def test_get_intent_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. @@ -1049,9 +1047,8 @@ async def test_get_intent_flattened_error_async(): ) -def test_create_intent( - transport: str = "grpc", request_type=gcd_intent.CreateIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_intent.CreateIntentRequest, dict,]) +def test_create_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1110,10 +1107,6 @@ def test_create_intent( assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_create_intent_from_dict(): - test_create_intent(request_type=dict) - - def test_create_intent_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. @@ -1341,9 +1334,8 @@ async def test_create_intent_flattened_error_async(): ) -def test_update_intent( - transport: str = "grpc", request_type=gcd_intent.UpdateIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_intent.UpdateIntentRequest, dict,]) +def test_update_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1402,10 +1394,6 @@ def test_update_intent( assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_update_intent_from_dict(): - test_update_intent(request_type=dict) - - def test_update_intent_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. @@ -1633,9 +1621,8 @@ async def test_update_intent_flattened_error_async(): ) -def test_delete_intent( - transport: str = "grpc", request_type=intent.DeleteIntentRequest -): +@pytest.mark.parametrize("request_type", [intent.DeleteIntentRequest, dict,]) +def test_delete_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1659,10 +1646,6 @@ def test_delete_intent( assert response is None -def test_delete_intent_from_dict(): - test_delete_intent(request_type=dict) - - def test_delete_intent_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. @@ -1825,9 +1808,8 @@ async def test_delete_intent_flattened_error_async(): ) -def test_batch_update_intents( - transport: str = "grpc", request_type=intent.BatchUpdateIntentsRequest -): +@pytest.mark.parametrize("request_type", [intent.BatchUpdateIntentsRequest, dict,]) +def test_batch_update_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1853,10 +1835,6 @@ def test_batch_update_intents( assert isinstance(response, future.Future) -def test_batch_update_intents_from_dict(): - test_batch_update_intents(request_type=dict) - - def test_batch_update_intents_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. @@ -2065,9 +2043,8 @@ async def test_batch_update_intents_flattened_error_async(): ) -def test_batch_delete_intents( - transport: str = "grpc", request_type=intent.BatchDeleteIntentsRequest -): +@pytest.mark.parametrize("request_type", [intent.BatchDeleteIntentsRequest, dict,]) +def test_batch_delete_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2093,10 +2070,6 @@ def test_batch_delete_intents( assert isinstance(response, future.Future) -def test_batch_delete_intents_from_dict(): - test_batch_delete_intents(request_type=dict) - - def test_batch_delete_intents_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. @@ -2859,7 +2832,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/dialogflow_v2/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py index d49c11ebe..8e15df623 100644 --- a/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2/test_knowledge_bases.py @@ -250,20 +250,20 @@ def test_knowledge_bases_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, @@ -322,7 +322,7 @@ def test_knowledge_bases_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 @@ -417,7 +417,7 @@ def test_knowledge_bases_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, @@ -448,7 +448,7 @@ def test_knowledge_bases_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", @@ -481,9 +481,10 @@ def test_knowledge_bases_client_client_options_from_dict(): ) -def test_list_knowledge_bases( - transport: str = "grpc", request_type=knowledge_base.ListKnowledgeBasesRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.ListKnowledgeBasesRequest, dict,] +) +def test_list_knowledge_bases(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -512,10 +513,6 @@ def test_list_knowledge_bases( assert response.next_page_token == "next_page_token_value" -def test_list_knowledge_bases_from_dict(): - test_list_knowledge_bases(request_type=dict) - - def test_list_knowledge_bases_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. @@ -706,8 +703,10 @@ async def test_list_knowledge_bases_flattened_error_async(): ) -def test_list_knowledge_bases_pager(): - client = KnowledgeBasesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_knowledge_bases_pager(transport_name: str = "grpc"): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -752,8 +751,10 @@ def test_list_knowledge_bases_pager(): assert all(isinstance(i, knowledge_base.KnowledgeBase) for i in results) -def test_list_knowledge_bases_pages(): - client = KnowledgeBasesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_knowledge_bases_pages(transport_name: str = "grpc"): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -876,9 +877,10 @@ async def test_list_knowledge_bases_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_knowledge_base( - transport: str = "grpc", request_type=knowledge_base.GetKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.GetKnowledgeBaseRequest, dict,] +) +def test_get_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -911,10 +913,6 @@ def test_get_knowledge_base( assert response.language_code == "language_code_value" -def test_get_knowledge_base_from_dict(): - test_get_knowledge_base(request_type=dict) - - def test_get_knowledge_base_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. @@ -1108,9 +1106,10 @@ async def test_get_knowledge_base_flattened_error_async(): ) -def test_create_knowledge_base( - transport: str = "grpc", request_type=gcd_knowledge_base.CreateKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_knowledge_base.CreateKnowledgeBaseRequest, dict,] +) +def test_create_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1143,10 +1142,6 @@ def test_create_knowledge_base( assert response.language_code == "language_code_value" -def test_create_knowledge_base_from_dict(): - test_create_knowledge_base(request_type=dict) - - def test_create_knowledge_base_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. @@ -1357,9 +1352,10 @@ async def test_create_knowledge_base_flattened_error_async(): ) -def test_delete_knowledge_base( - transport: str = "grpc", request_type=knowledge_base.DeleteKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.DeleteKnowledgeBaseRequest, dict,] +) +def test_delete_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1385,10 +1381,6 @@ def test_delete_knowledge_base( assert response is None -def test_delete_knowledge_base_from_dict(): - test_delete_knowledge_base(request_type=dict) - - def test_delete_knowledge_base_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. @@ -1570,9 +1562,10 @@ async def test_delete_knowledge_base_flattened_error_async(): ) -def test_update_knowledge_base( - transport: str = "grpc", request_type=gcd_knowledge_base.UpdateKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_knowledge_base.UpdateKnowledgeBaseRequest, dict,] +) +def test_update_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1605,10 +1598,6 @@ def test_update_knowledge_base( assert response.language_code == "language_code_value" -def test_update_knowledge_base_from_dict(): - test_update_knowledge_base(request_type=dict) - - def test_update_knowledge_base_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. @@ -2353,7 +2342,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/dialogflow_v2/test_participants.py b/tests/unit/gapic/dialogflow_v2/test_participants.py index 84c4d9683..2dd15c961 100644 --- a/tests/unit/gapic/dialogflow_v2/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2/test_participants.py @@ -246,20 +246,20 @@ def test_participants_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_participants_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_participants_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_participants_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,10 @@ def test_participants_client_client_options_from_dict(): ) -def test_create_participant( - transport: str = "grpc", request_type=gcd_participant.CreateParticipantRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_participant.CreateParticipantRequest, dict,] +) +def test_create_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -508,10 +509,6 @@ def test_create_participant( assert response.sip_recording_media_label == "sip_recording_media_label_value" -def test_create_participant_from_dict(): - test_create_participant(request_type=dict) - - def test_create_participant_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. @@ -716,9 +713,8 @@ async def test_create_participant_flattened_error_async(): ) -def test_get_participant( - transport: str = "grpc", request_type=participant.GetParticipantRequest -): +@pytest.mark.parametrize("request_type", [participant.GetParticipantRequest, dict,]) +def test_get_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -749,10 +745,6 @@ def test_get_participant( assert response.sip_recording_media_label == "sip_recording_media_label_value" -def test_get_participant_from_dict(): - test_get_participant(request_type=dict) - - def test_get_participant_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. @@ -928,9 +920,8 @@ async def test_get_participant_flattened_error_async(): ) -def test_list_participants( - transport: str = "grpc", request_type=participant.ListParticipantsRequest -): +@pytest.mark.parametrize("request_type", [participant.ListParticipantsRequest, dict,]) +def test_list_participants(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -959,10 +950,6 @@ def test_list_participants( assert response.next_page_token == "next_page_token_value" -def test_list_participants_from_dict(): - test_list_participants(request_type=dict) - - def test_list_participants_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. @@ -1146,8 +1133,10 @@ async def test_list_participants_flattened_error_async(): ) -def test_list_participants_pager(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_participants_pager(transport_name: str = "grpc"): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1188,8 +1177,10 @@ def test_list_participants_pager(): assert all(isinstance(i, participant.Participant) for i in results) -def test_list_participants_pages(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_participants_pages(transport_name: str = "grpc"): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1300,9 +1291,10 @@ async def test_list_participants_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_participant( - transport: str = "grpc", request_type=gcd_participant.UpdateParticipantRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_participant.UpdateParticipantRequest, dict,] +) +def test_update_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1335,10 +1327,6 @@ def test_update_participant( assert response.sip_recording_media_label == "sip_recording_media_label_value" -def test_update_participant_from_dict(): - test_update_participant(request_type=dict) - - def test_update_participant_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. @@ -1547,9 +1535,8 @@ async def test_update_participant_flattened_error_async(): ) -def test_analyze_content( - transport: str = "grpc", request_type=gcd_participant.AnalyzeContentRequest -): +@pytest.mark.parametrize("request_type", [gcd_participant.AnalyzeContentRequest, dict,]) +def test_analyze_content(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1576,10 +1563,6 @@ def test_analyze_content( assert response.reply_text == "reply_text_value" -def test_analyze_content_from_dict(): - test_analyze_content(request_type=dict) - - def test_analyze_content_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. @@ -1765,9 +1748,8 @@ async def test_analyze_content_flattened_error_async(): ) -def test_suggest_articles( - transport: str = "grpc", request_type=participant.SuggestArticlesRequest -): +@pytest.mark.parametrize("request_type", [participant.SuggestArticlesRequest, dict,]) +def test_suggest_articles(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1795,10 +1777,6 @@ def test_suggest_articles( assert response.context_size == 1311 -def test_suggest_articles_from_dict(): - test_suggest_articles(request_type=dict) - - def test_suggest_articles_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. @@ -1971,9 +1949,8 @@ async def test_suggest_articles_flattened_error_async(): ) -def test_suggest_faq_answers( - transport: str = "grpc", request_type=participant.SuggestFaqAnswersRequest -): +@pytest.mark.parametrize("request_type", [participant.SuggestFaqAnswersRequest, dict,]) +def test_suggest_faq_answers(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2003,10 +1980,6 @@ def test_suggest_faq_answers( assert response.context_size == 1311 -def test_suggest_faq_answers_from_dict(): - test_suggest_faq_answers(request_type=dict) - - def test_suggest_faq_answers_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. @@ -2806,7 +2779,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/dialogflow_v2/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py index f6a4d4877..5d51ebf34 100644 --- a/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2/test_session_entity_types.py @@ -256,20 +256,20 @@ def test_session_entity_types_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, @@ -338,7 +338,7 @@ def test_session_entity_types_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 @@ -433,7 +433,7 @@ def test_session_entity_types_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, @@ -464,7 +464,7 @@ def test_session_entity_types_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", @@ -497,10 +497,10 @@ def test_session_entity_types_client_client_options_from_dict(): ) -def test_list_session_entity_types( - transport: str = "grpc", - request_type=session_entity_type.ListSessionEntityTypesRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.ListSessionEntityTypesRequest, dict,] +) +def test_list_session_entity_types(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -529,10 +529,6 @@ def test_list_session_entity_types( assert response.next_page_token == "next_page_token_value" -def test_list_session_entity_types_from_dict(): - test_list_session_entity_types(request_type=dict) - - def test_list_session_entity_types_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. @@ -729,8 +725,10 @@ async def test_list_session_entity_types_flattened_error_async(): ) -def test_list_session_entity_types_pager(): - client = SessionEntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_session_entity_types_pager(transport_name: str = "grpc"): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -777,8 +775,10 @@ def test_list_session_entity_types_pager(): ) -def test_list_session_entity_types_pages(): - client = SessionEntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_session_entity_types_pages(transport_name: str = "grpc"): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -907,10 +907,10 @@ async def test_list_session_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_session_entity_type( - transport: str = "grpc", - request_type=session_entity_type.GetSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.GetSessionEntityTypeRequest, dict,] +) +def test_get_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -944,10 +944,6 @@ def test_get_session_entity_type( ) -def test_get_session_entity_type_from_dict(): - test_get_session_entity_type(request_type=dict) - - def test_get_session_entity_type_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. @@ -1149,10 +1145,10 @@ async def test_get_session_entity_type_flattened_error_async(): ) -def test_create_session_entity_type( - transport: str = "grpc", - request_type=gcd_session_entity_type.CreateSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_session_entity_type.CreateSessionEntityTypeRequest, dict,] +) +def test_create_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1186,10 +1182,6 @@ def test_create_session_entity_type( ) -def test_create_session_entity_type_from_dict(): - test_create_session_entity_type(request_type=dict) - - def test_create_session_entity_type_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. @@ -1415,10 +1407,10 @@ async def test_create_session_entity_type_flattened_error_async(): ) -def test_update_session_entity_type( - transport: str = "grpc", - request_type=gcd_session_entity_type.UpdateSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_session_entity_type.UpdateSessionEntityTypeRequest, dict,] +) +def test_update_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1452,10 +1444,6 @@ def test_update_session_entity_type( ) -def test_update_session_entity_type_from_dict(): - test_update_session_entity_type(request_type=dict) - - def test_update_session_entity_type_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. @@ -1687,10 +1675,10 @@ async def test_update_session_entity_type_flattened_error_async(): ) -def test_delete_session_entity_type( - transport: str = "grpc", - request_type=session_entity_type.DeleteSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.DeleteSessionEntityTypeRequest, dict,] +) +def test_delete_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1716,10 +1704,6 @@ def test_delete_session_entity_type( assert response is None -def test_delete_session_entity_type_from_dict(): - test_delete_session_entity_type(request_type=dict) - - def test_delete_session_entity_type_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. @@ -2443,7 +2427,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/dialogflow_v2/test_sessions.py b/tests/unit/gapic/dialogflow_v2/test_sessions.py index 4450d9cfa..d51c79a07 100644 --- a/tests/unit/gapic/dialogflow_v2/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2/test_sessions.py @@ -237,20 +237,20 @@ def test_sessions_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_sessions_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_sessions_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_sessions_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_sessions_client_client_options_from_dict(): ) -def test_detect_intent( - transport: str = "grpc", request_type=gcd_session.DetectIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_session.DetectIntentRequest, dict,]) +def test_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -486,10 +485,6 @@ def test_detect_intent( assert response.output_audio == b"output_audio_blob" -def test_detect_intent_from_dict(): - test_detect_intent(request_type=dict) - - def test_detect_intent_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. @@ -702,9 +697,8 @@ async def test_detect_intent_flattened_error_async(): ) -def test_streaming_detect_intent( - transport: str = "grpc", request_type=session.StreamingDetectIntentRequest -): +@pytest.mark.parametrize("request_type", [session.StreamingDetectIntentRequest, dict,]) +def test_streaming_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -732,10 +726,6 @@ def test_streaming_detect_intent( assert isinstance(message, session.StreamingDetectIntentResponse) -def test_streaming_detect_intent_from_dict(): - test_streaming_detect_intent(request_type=dict) - - @pytest.mark.asyncio async def test_streaming_detect_intent_async( transport: str = "grpc_asyncio", request_type=session.StreamingDetectIntentRequest @@ -1353,7 +1343,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/dialogflow_v2/test_versions.py b/tests/unit/gapic/dialogflow_v2/test_versions.py index e2fad9e8d..a1735e030 100644 --- a/tests/unit/gapic/dialogflow_v2/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2/test_versions.py @@ -232,20 +232,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, @@ -302,7 +302,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 @@ -393,7 +393,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, @@ -420,7 +420,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", @@ -451,9 +451,8 @@ def test_versions_client_client_options_from_dict(): ) -def test_list_versions( - transport: str = "grpc", request_type=version.ListVersionsRequest -): +@pytest.mark.parametrize("request_type", [version.ListVersionsRequest, dict,]) +def test_list_versions(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -480,10 +479,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. @@ -653,8 +648,10 @@ async def test_list_versions_flattened_error_async(): ) -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: @@ -687,8 +684,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: @@ -775,7 +774,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=version.GetVersionRequest): +@pytest.mark.parametrize("request_type", [version.GetVersionRequest, dict,]) +def test_get_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -808,10 +808,6 @@ def test_get_version(transport: str = "grpc", request_type=version.GetVersionReq assert response.status == version.Version.VersionStatus.IN_PROGRESS -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. @@ -985,9 +981,8 @@ async def test_get_version_flattened_error_async(): ) -def test_create_version( - transport: str = "grpc", request_type=gcd_version.CreateVersionRequest -): +@pytest.mark.parametrize("request_type", [gcd_version.CreateVersionRequest, dict,]) +def test_create_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1020,10 +1015,6 @@ def test_create_version( assert response.status == gcd_version.Version.VersionStatus.IN_PROGRESS -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. @@ -1211,9 +1202,8 @@ async def test_create_version_flattened_error_async(): ) -def test_update_version( - transport: str = "grpc", request_type=gcd_version.UpdateVersionRequest -): +@pytest.mark.parametrize("request_type", [gcd_version.UpdateVersionRequest, dict,]) +def test_update_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1246,10 +1236,6 @@ def test_update_version( assert response.status == gcd_version.Version.VersionStatus.IN_PROGRESS -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. @@ -1443,9 +1429,8 @@ async def test_update_version_flattened_error_async(): ) -def test_delete_version( - transport: str = "grpc", request_type=version.DeleteVersionRequest -): +@pytest.mark.parametrize("request_type", [version.DeleteVersionRequest, dict,]) +def test_delete_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1469,10 +1454,6 @@ def test_delete_version( assert response is None -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. @@ -2146,7 +2127,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/dialogflow_v2beta1/test_agents.py b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py index 35423f578..4ec55170b 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_agents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_agents.py @@ -232,20 +232,20 @@ def test_agents_client_client_options(client_class, transport_class, transport_n # 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, @@ -300,7 +300,7 @@ def test_agents_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 @@ -391,7 +391,7 @@ def test_agents_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, @@ -418,7 +418,7 @@ def test_agents_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", @@ -449,7 +449,8 @@ def test_agents_client_client_options_from_dict(): ) -def test_get_agent(transport: str = "grpc", request_type=agent.GetAgentRequest): +@pytest.mark.parametrize("request_type", [agent.GetAgentRequest, dict,]) +def test_get_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -500,10 +501,6 @@ def test_get_agent(transport: str = "grpc", request_type=agent.GetAgentRequest): assert response.tier == agent.Agent.Tier.TIER_STANDARD -def test_get_agent_from_dict(): - test_get_agent(request_type=dict) - - def test_get_agent_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. @@ -695,7 +692,8 @@ async def test_get_agent_flattened_error_async(): ) -def test_set_agent(transport: str = "grpc", request_type=gcd_agent.SetAgentRequest): +@pytest.mark.parametrize("request_type", [gcd_agent.SetAgentRequest, dict,]) +def test_set_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -746,10 +744,6 @@ def test_set_agent(transport: str = "grpc", request_type=gcd_agent.SetAgentReque assert response.tier == gcd_agent.Agent.Tier.TIER_STANDARD -def test_set_agent_from_dict(): - test_set_agent(request_type=dict) - - def test_set_agent_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. @@ -945,7 +939,8 @@ async def test_set_agent_flattened_error_async(): ) -def test_delete_agent(transport: str = "grpc", request_type=agent.DeleteAgentRequest): +@pytest.mark.parametrize("request_type", [agent.DeleteAgentRequest, dict,]) +def test_delete_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -969,10 +964,6 @@ def test_delete_agent(transport: str = "grpc", request_type=agent.DeleteAgentReq assert response is None -def test_delete_agent_from_dict(): - test_delete_agent(request_type=dict) - - def test_delete_agent_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,7 +1126,8 @@ async def test_delete_agent_flattened_error_async(): ) -def test_search_agents(transport: str = "grpc", request_type=agent.SearchAgentsRequest): +@pytest.mark.parametrize("request_type", [agent.SearchAgentsRequest, dict,]) +def test_search_agents(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1162,10 +1154,6 @@ def test_search_agents(transport: str = "grpc", request_type=agent.SearchAgentsR assert response.next_page_token == "next_page_token_value" -def test_search_agents_from_dict(): - test_search_agents(request_type=dict) - - def test_search_agents_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. @@ -1335,8 +1323,10 @@ async def test_search_agents_flattened_error_async(): ) -def test_search_agents_pager(): - client = AgentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_agents_pager(transport_name: str = "grpc"): + client = AgentsClient( + 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.search_agents), "__call__") as call: @@ -1365,8 +1355,10 @@ def test_search_agents_pager(): assert all(isinstance(i, agent.Agent) for i in results) -def test_search_agents_pages(): - client = AgentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_agents_pages(transport_name: str = "grpc"): + client = AgentsClient( + 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.search_agents), "__call__") as call: @@ -1441,7 +1433,8 @@ async def test_search_agents_async_pages(): assert page_.raw_page.next_page_token == token -def test_train_agent(transport: str = "grpc", request_type=agent.TrainAgentRequest): +@pytest.mark.parametrize("request_type", [agent.TrainAgentRequest, dict,]) +def test_train_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1465,10 +1458,6 @@ def test_train_agent(transport: str = "grpc", request_type=agent.TrainAgentReque assert isinstance(response, future.Future) -def test_train_agent_from_dict(): - test_train_agent(request_type=dict) - - def test_train_agent_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. @@ -1637,7 +1626,8 @@ async def test_train_agent_flattened_error_async(): ) -def test_export_agent(transport: str = "grpc", request_type=agent.ExportAgentRequest): +@pytest.mark.parametrize("request_type", [agent.ExportAgentRequest, dict,]) +def test_export_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1661,10 +1651,6 @@ def test_export_agent(transport: str = "grpc", request_type=agent.ExportAgentReq assert isinstance(response, future.Future) -def test_export_agent_from_dict(): - test_export_agent(request_type=dict) - - def test_export_agent_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. @@ -1833,7 +1819,8 @@ async def test_export_agent_flattened_error_async(): ) -def test_import_agent(transport: str = "grpc", request_type=agent.ImportAgentRequest): +@pytest.mark.parametrize("request_type", [agent.ImportAgentRequest, dict,]) +def test_import_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1857,10 +1844,6 @@ def test_import_agent(transport: str = "grpc", request_type=agent.ImportAgentReq assert isinstance(response, future.Future) -def test_import_agent_from_dict(): - test_import_agent(request_type=dict) - - def test_import_agent_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. @@ -1961,7 +1944,8 @@ async def test_import_agent_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_restore_agent(transport: str = "grpc", request_type=agent.RestoreAgentRequest): +@pytest.mark.parametrize("request_type", [agent.RestoreAgentRequest, dict,]) +def test_restore_agent(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1985,10 +1969,6 @@ def test_restore_agent(transport: str = "grpc", request_type=agent.RestoreAgentR assert isinstance(response, future.Future) -def test_restore_agent_from_dict(): - test_restore_agent(request_type=dict) - - def test_restore_agent_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. @@ -2089,9 +2069,8 @@ async def test_restore_agent_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_validation_result( - transport: str = "grpc", request_type=agent.GetValidationResultRequest -): +@pytest.mark.parametrize("request_type", [agent.GetValidationResultRequest, dict,]) +def test_get_validation_result(request_type, transport: str = "grpc"): client = AgentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2117,10 +2096,6 @@ def test_get_validation_result( assert isinstance(response, validation_result.ValidationResult) -def test_get_validation_result_from_dict(): - test_get_validation_result(request_type=dict) - - def test_get_validation_result_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. @@ -2771,7 +2746,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/dialogflow_v2beta1/test_answer_records.py b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py index ced898e69..71ca27e26 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_answer_records.py @@ -252,20 +252,20 @@ def test_answer_records_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, @@ -324,7 +324,7 @@ def test_answer_records_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 @@ -419,7 +419,7 @@ def test_answer_records_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, @@ -450,7 +450,7 @@ def test_answer_records_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", @@ -483,9 +483,8 @@ def test_answer_records_client_client_options_from_dict(): ) -def test_get_answer_record( - transport: str = "grpc", request_type=answer_record.GetAnswerRecordRequest -): +@pytest.mark.parametrize("request_type", [answer_record.GetAnswerRecordRequest, dict,]) +def test_get_answer_record(request_type, transport: str = "grpc"): client = AnswerRecordsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -517,10 +516,6 @@ def test_get_answer_record( assert response.name == "name_value" -def test_get_answer_record_from_dict(): - test_get_answer_record(request_type=dict) - - def test_get_answer_record_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. @@ -632,9 +627,10 @@ async def test_get_answer_record_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_list_answer_records( - transport: str = "grpc", request_type=answer_record.ListAnswerRecordsRequest -): +@pytest.mark.parametrize( + "request_type", [answer_record.ListAnswerRecordsRequest, dict,] +) +def test_list_answer_records(request_type, transport: str = "grpc"): client = AnswerRecordsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -663,10 +659,6 @@ def test_list_answer_records( assert response.next_page_token == "next_page_token_value" -def test_list_answer_records_from_dict(): - test_list_answer_records(request_type=dict) - - def test_list_answer_records_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. @@ -856,8 +848,10 @@ async def test_list_answer_records_flattened_error_async(): ) -def test_list_answer_records_pager(): - client = AnswerRecordsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_answer_records_pager(transport_name: str = "grpc"): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -901,8 +895,10 @@ def test_list_answer_records_pager(): assert all(isinstance(i, answer_record.AnswerRecord) for i in results) -def test_list_answer_records_pages(): - client = AnswerRecordsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_answer_records_pages(transport_name: str = "grpc"): + client = AnswerRecordsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1022,9 +1018,10 @@ async def test_list_answer_records_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_answer_record( - transport: str = "grpc", request_type=gcd_answer_record.UpdateAnswerRecordRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_answer_record.UpdateAnswerRecordRequest, dict,] +) +def test_update_answer_record(request_type, transport: str = "grpc"): client = AnswerRecordsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1056,10 +1053,6 @@ def test_update_answer_record( assert response.name == "name_value" -def test_update_answer_record_from_dict(): - test_update_answer_record(request_type=dict) - - def test_update_answer_record_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. @@ -1794,7 +1787,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/dialogflow_v2beta1/test_contexts.py b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py index 9951713d9..27625ffa9 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_contexts.py @@ -232,20 +232,20 @@ def test_contexts_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, @@ -302,7 +302,7 @@ def test_contexts_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 @@ -393,7 +393,7 @@ def test_contexts_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, @@ -420,7 +420,7 @@ def test_contexts_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", @@ -451,9 +451,8 @@ def test_contexts_client_client_options_from_dict(): ) -def test_list_contexts( - transport: str = "grpc", request_type=context.ListContextsRequest -): +@pytest.mark.parametrize("request_type", [context.ListContextsRequest, dict,]) +def test_list_contexts(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -480,10 +479,6 @@ def test_list_contexts( assert response.next_page_token == "next_page_token_value" -def test_list_contexts_from_dict(): - test_list_contexts(request_type=dict) - - def test_list_contexts_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. @@ -653,8 +648,10 @@ async def test_list_contexts_flattened_error_async(): ) -def test_list_contexts_pager(): - client = ContextsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pager(transport_name: str = "grpc"): + client = ContextsClient( + 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_contexts), "__call__") as call: @@ -687,8 +684,10 @@ def test_list_contexts_pager(): assert all(isinstance(i, context.Context) for i in results) -def test_list_contexts_pages(): - client = ContextsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pages(transport_name: str = "grpc"): + client = ContextsClient( + 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_contexts), "__call__") as call: @@ -775,7 +774,8 @@ async def test_list_contexts_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_context(transport: str = "grpc", request_type=context.GetContextRequest): +@pytest.mark.parametrize("request_type", [context.GetContextRequest, dict,]) +def test_get_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -801,10 +801,6 @@ def test_get_context(transport: str = "grpc", request_type=context.GetContextReq assert response.lifespan_count == 1498 -def test_get_context_from_dict(): - test_get_context(request_type=dict) - - def test_get_context_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. @@ -971,9 +967,8 @@ async def test_get_context_flattened_error_async(): ) -def test_create_context( - transport: str = "grpc", request_type=gcd_context.CreateContextRequest -): +@pytest.mark.parametrize("request_type", [gcd_context.CreateContextRequest, dict,]) +def test_create_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -999,10 +994,6 @@ def test_create_context( assert response.lifespan_count == 1498 -def test_create_context_from_dict(): - test_create_context(request_type=dict) - - def test_create_context_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. @@ -1183,9 +1174,8 @@ async def test_create_context_flattened_error_async(): ) -def test_update_context( - transport: str = "grpc", request_type=gcd_context.UpdateContextRequest -): +@pytest.mark.parametrize("request_type", [gcd_context.UpdateContextRequest, dict,]) +def test_update_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1211,10 +1201,6 @@ def test_update_context( assert response.lifespan_count == 1498 -def test_update_context_from_dict(): - test_update_context(request_type=dict) - - def test_update_context_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. @@ -1401,9 +1387,8 @@ async def test_update_context_flattened_error_async(): ) -def test_delete_context( - transport: str = "grpc", request_type=context.DeleteContextRequest -): +@pytest.mark.parametrize("request_type", [context.DeleteContextRequest, dict,]) +def test_delete_context(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1427,10 +1412,6 @@ def test_delete_context( assert response is None -def test_delete_context_from_dict(): - test_delete_context(request_type=dict) - - def test_delete_context_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. @@ -1593,9 +1574,8 @@ async def test_delete_context_flattened_error_async(): ) -def test_delete_all_contexts( - transport: str = "grpc", request_type=context.DeleteAllContextsRequest -): +@pytest.mark.parametrize("request_type", [context.DeleteAllContextsRequest, dict,]) +def test_delete_all_contexts(request_type, transport: str = "grpc"): client = ContextsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1621,10 +1601,6 @@ def test_delete_all_contexts( assert response is None -def test_delete_all_contexts_from_dict(): - test_delete_all_contexts(request_type=dict) - - def test_delete_all_contexts_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. @@ -2313,7 +2289,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/dialogflow_v2beta1/test_conversation_profiles.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py index c00233ed7..20574f832 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversation_profiles.py @@ -262,20 +262,20 @@ def test_conversation_profiles_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_conversation_profiles_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 @@ -443,7 +443,7 @@ def test_conversation_profiles_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, @@ -478,7 +478,7 @@ def test_conversation_profiles_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", @@ -511,10 +511,10 @@ def test_conversation_profiles_client_client_options_from_dict(): ) -def test_list_conversation_profiles( - transport: str = "grpc", - request_type=conversation_profile.ListConversationProfilesRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.ListConversationProfilesRequest, dict,] +) +def test_list_conversation_profiles(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -543,10 +543,6 @@ def test_list_conversation_profiles( assert response.next_page_token == "next_page_token_value" -def test_list_conversation_profiles_from_dict(): - test_list_conversation_profiles(request_type=dict) - - def test_list_conversation_profiles_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. @@ -745,9 +741,9 @@ async def test_list_conversation_profiles_flattened_error_async(): ) -def test_list_conversation_profiles_pager(): +def test_list_conversation_profiles_pager(transport_name: str = "grpc"): client = ConversationProfilesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -795,9 +791,9 @@ def test_list_conversation_profiles_pager(): ) -def test_list_conversation_profiles_pages(): +def test_list_conversation_profiles_pages(transport_name: str = "grpc"): client = ConversationProfilesClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -927,10 +923,10 @@ async def test_list_conversation_profiles_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_conversation_profile( - transport: str = "grpc", - request_type=conversation_profile.GetConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.GetConversationProfileRequest, dict,] +) +def test_get_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -967,10 +963,6 @@ def test_get_conversation_profile( assert response.security_settings == "security_settings_value" -def test_get_conversation_profile_from_dict(): - test_get_conversation_profile(request_type=dict) - - def test_get_conversation_profile_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. @@ -1175,10 +1167,10 @@ async def test_get_conversation_profile_flattened_error_async(): ) -def test_create_conversation_profile( - transport: str = "grpc", - request_type=gcd_conversation_profile.CreateConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation_profile.CreateConversationProfileRequest, dict,] +) +def test_create_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1215,10 +1207,6 @@ def test_create_conversation_profile( assert response.security_settings == "security_settings_value" -def test_create_conversation_profile_from_dict(): - test_create_conversation_profile(request_type=dict) - - def test_create_conversation_profile_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. @@ -1447,10 +1435,10 @@ async def test_create_conversation_profile_flattened_error_async(): ) -def test_update_conversation_profile( - transport: str = "grpc", - request_type=gcd_conversation_profile.UpdateConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation_profile.UpdateConversationProfileRequest, dict,] +) +def test_update_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1487,10 +1475,6 @@ def test_update_conversation_profile( assert response.security_settings == "security_settings_value" -def test_update_conversation_profile_from_dict(): - test_update_conversation_profile(request_type=dict) - - def test_update_conversation_profile_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. @@ -1725,10 +1709,10 @@ async def test_update_conversation_profile_flattened_error_async(): ) -def test_delete_conversation_profile( - transport: str = "grpc", - request_type=conversation_profile.DeleteConversationProfileRequest, -): +@pytest.mark.parametrize( + "request_type", [conversation_profile.DeleteConversationProfileRequest, dict,] +) +def test_delete_conversation_profile(request_type, transport: str = "grpc"): client = ConversationProfilesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1754,10 +1738,6 @@ def test_delete_conversation_profile( assert response is None -def test_delete_conversation_profile_from_dict(): - test_delete_conversation_profile(request_type=dict) - - def test_delete_conversation_profile_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. @@ -2595,7 +2575,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/dialogflow_v2beta1/test_conversations.py b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py index c65a290d3..d0f94ba48 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_conversations.py @@ -253,20 +253,20 @@ def test_conversations_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, @@ -325,7 +325,7 @@ def test_conversations_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 @@ -420,7 +420,7 @@ def test_conversations_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, @@ -451,7 +451,7 @@ def test_conversations_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", @@ -484,9 +484,10 @@ def test_conversations_client_client_options_from_dict(): ) -def test_create_conversation( - transport: str = "grpc", request_type=gcd_conversation.CreateConversationRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_conversation.CreateConversationRequest, dict,] +) +def test_create_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -527,10 +528,6 @@ def test_create_conversation( ) -def test_create_conversation_from_dict(): - test_create_conversation(request_type=dict) - - def test_create_conversation_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. @@ -749,9 +746,8 @@ async def test_create_conversation_flattened_error_async(): ) -def test_list_conversations( - transport: str = "grpc", request_type=conversation.ListConversationsRequest -): +@pytest.mark.parametrize("request_type", [conversation.ListConversationsRequest, dict,]) +def test_list_conversations(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -780,10 +776,6 @@ def test_list_conversations( assert response.next_page_token == "next_page_token_value" -def test_list_conversations_from_dict(): - test_list_conversations(request_type=dict) - - def test_list_conversations_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. @@ -973,8 +965,10 @@ async def test_list_conversations_flattened_error_async(): ) -def test_list_conversations_pager(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_conversations_pager(transport_name: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1018,8 +1012,10 @@ def test_list_conversations_pager(): assert all(isinstance(i, conversation.Conversation) for i in results) -def test_list_conversations_pages(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_conversations_pages(transport_name: str = "grpc"): + client = ConversationsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1139,9 +1135,8 @@ async def test_list_conversations_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_conversation( - transport: str = "grpc", request_type=conversation.GetConversationRequest -): +@pytest.mark.parametrize("request_type", [conversation.GetConversationRequest, dict,]) +def test_get_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1179,10 +1174,6 @@ def test_get_conversation( ) -def test_get_conversation_from_dict(): - test_get_conversation(request_type=dict) - - def test_get_conversation_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. @@ -1371,9 +1362,10 @@ async def test_get_conversation_flattened_error_async(): ) -def test_complete_conversation( - transport: str = "grpc", request_type=conversation.CompleteConversationRequest -): +@pytest.mark.parametrize( + "request_type", [conversation.CompleteConversationRequest, dict,] +) +def test_complete_conversation(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1413,10 +1405,6 @@ def test_complete_conversation( ) -def test_complete_conversation_from_dict(): - test_complete_conversation(request_type=dict) - - def test_complete_conversation_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. @@ -1618,9 +1606,10 @@ async def test_complete_conversation_flattened_error_async(): ) -def test_batch_create_messages( - transport: str = "grpc", request_type=conversation.BatchCreateMessagesRequest -): +@pytest.mark.parametrize( + "request_type", [conversation.BatchCreateMessagesRequest, dict,] +) +def test_batch_create_messages(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1646,10 +1635,6 @@ def test_batch_create_messages( assert isinstance(response, conversation.BatchCreateMessagesResponse) -def test_batch_create_messages_from_dict(): - test_batch_create_messages(request_type=dict) - - def test_batch_create_messages_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. @@ -1837,9 +1822,8 @@ async def test_batch_create_messages_flattened_error_async(): ) -def test_list_messages( - transport: str = "grpc", request_type=conversation.ListMessagesRequest -): +@pytest.mark.parametrize("request_type", [conversation.ListMessagesRequest, dict,]) +def test_list_messages(request_type, transport: str = "grpc"): client = ConversationsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1866,10 +1850,6 @@ def test_list_messages( assert response.next_page_token == "next_page_token_value" -def test_list_messages_from_dict(): - test_list_messages(request_type=dict) - - def test_list_messages_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. @@ -2045,8 +2025,10 @@ async def test_list_messages_flattened_error_async(): ) -def test_list_messages_pager(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_messages_pager(transport_name: str = "grpc"): + client = ConversationsClient( + 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_messages), "__call__") as call: @@ -2083,8 +2065,10 @@ def test_list_messages_pager(): assert all(isinstance(i, participant.Message) for i in results) -def test_list_messages_pages(): - client = ConversationsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_messages_pages(transport_name: str = "grpc"): + client = ConversationsClient( + 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_messages), "__call__") as call: @@ -2758,7 +2742,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/dialogflow_v2beta1/test_documents.py b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py index 3d7d5a27e..1f057c497 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_documents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_documents.py @@ -243,20 +243,20 @@ def test_documents_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, @@ -313,7 +313,7 @@ def test_documents_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 @@ -408,7 +408,7 @@ def test_documents_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, @@ -439,7 +439,7 @@ def test_documents_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", @@ -470,9 +470,8 @@ def test_documents_client_client_options_from_dict(): ) -def test_list_documents( - transport: str = "grpc", request_type=document.ListDocumentsRequest -): +@pytest.mark.parametrize("request_type", [document.ListDocumentsRequest, dict,]) +def test_list_documents(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -499,10 +498,6 @@ def test_list_documents( assert response.next_page_token == "next_page_token_value" -def test_list_documents_from_dict(): - test_list_documents(request_type=dict) - - def test_list_documents_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. @@ -672,8 +667,10 @@ async def test_list_documents_flattened_error_async(): ) -def test_list_documents_pager(): - client = DocumentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_documents_pager(transport_name: str = "grpc"): + client = DocumentsClient( + 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_documents), "__call__") as call: @@ -710,8 +707,10 @@ def test_list_documents_pager(): assert all(isinstance(i, document.Document) for i in results) -def test_list_documents_pages(): - client = DocumentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_documents_pages(transport_name: str = "grpc"): + client = DocumentsClient( + 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_documents), "__call__") as call: @@ -810,9 +809,8 @@ async def test_list_documents_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_document( - transport: str = "grpc", request_type=document.GetDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.GetDocumentRequest, dict,]) +def test_get_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -848,10 +846,6 @@ def test_get_document( assert response.enable_auto_reload is True -def test_get_document_from_dict(): - test_get_document(request_type=dict) - - def test_get_document_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. @@ -1027,9 +1021,8 @@ async def test_get_document_flattened_error_async(): ) -def test_create_document( - transport: str = "grpc", request_type=gcd_document.CreateDocumentRequest -): +@pytest.mark.parametrize("request_type", [gcd_document.CreateDocumentRequest, dict,]) +def test_create_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1053,10 +1046,6 @@ def test_create_document( assert isinstance(response, future.Future) -def test_create_document_from_dict(): - test_create_document(request_type=dict) - - def test_create_document_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. @@ -1239,9 +1228,8 @@ async def test_create_document_flattened_error_async(): ) -def test_import_documents( - transport: str = "grpc", request_type=document.ImportDocumentsRequest -): +@pytest.mark.parametrize("request_type", [document.ImportDocumentsRequest, dict,]) +def test_import_documents(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1265,10 +1253,6 @@ def test_import_documents( assert isinstance(response, future.Future) -def test_import_documents_from_dict(): - test_import_documents(request_type=dict) - - def test_import_documents_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. @@ -1369,9 +1353,8 @@ async def test_import_documents_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_delete_document( - transport: str = "grpc", request_type=document.DeleteDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.DeleteDocumentRequest, dict,]) +def test_delete_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1395,10 +1378,6 @@ def test_delete_document( assert isinstance(response, future.Future) -def test_delete_document_from_dict(): - test_delete_document(request_type=dict) - - def test_delete_document_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. @@ -1567,9 +1546,8 @@ async def test_delete_document_flattened_error_async(): ) -def test_update_document( - transport: str = "grpc", request_type=gcd_document.UpdateDocumentRequest -): +@pytest.mark.parametrize("request_type", [gcd_document.UpdateDocumentRequest, dict,]) +def test_update_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1593,10 +1571,6 @@ def test_update_document( assert isinstance(response, future.Future) -def test_update_document_from_dict(): - test_update_document(request_type=dict) - - def test_update_document_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. @@ -1785,9 +1759,8 @@ async def test_update_document_flattened_error_async(): ) -def test_reload_document( - transport: str = "grpc", request_type=document.ReloadDocumentRequest -): +@pytest.mark.parametrize("request_type", [document.ReloadDocumentRequest, dict,]) +def test_reload_document(request_type, transport: str = "grpc"): client = DocumentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1811,10 +1784,6 @@ def test_reload_document( assert isinstance(response, future.Future) -def test_reload_document_from_dict(): - test_reload_document(request_type=dict) - - def test_reload_document_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. @@ -2539,7 +2508,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/dialogflow_v2beta1/test_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py index 52eb0d9bb..0e4907a9a 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_entity_types.py @@ -244,20 +244,20 @@ def test_entity_types_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, @@ -314,7 +314,7 @@ def test_entity_types_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 @@ -409,7 +409,7 @@ def test_entity_types_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, @@ -440,7 +440,7 @@ def test_entity_types_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", @@ -471,9 +471,8 @@ def test_entity_types_client_client_options_from_dict(): ) -def test_list_entity_types( - transport: str = "grpc", request_type=entity_type.ListEntityTypesRequest -): +@pytest.mark.parametrize("request_type", [entity_type.ListEntityTypesRequest, dict,]) +def test_list_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -502,10 +501,6 @@ def test_list_entity_types( assert response.next_page_token == "next_page_token_value" -def test_list_entity_types_from_dict(): - test_list_entity_types(request_type=dict) - - def test_list_entity_types_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. @@ -703,8 +698,10 @@ async def test_list_entity_types_flattened_error_async(): ) -def test_list_entity_types_pager(): - client = EntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pager(transport_name: str = "grpc"): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -745,8 +742,10 @@ def test_list_entity_types_pager(): assert all(isinstance(i, entity_type.EntityType) for i in results) -def test_list_entity_types_pages(): - client = EntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pages(transport_name: str = "grpc"): + client = EntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -857,9 +856,8 @@ async def test_list_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_entity_type( - transport: str = "grpc", request_type=entity_type.GetEntityTypeRequest -): +@pytest.mark.parametrize("request_type", [entity_type.GetEntityTypeRequest, dict,]) +def test_get_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -897,10 +895,6 @@ def test_get_entity_type( assert response.enable_fuzzy_extraction is True -def test_get_entity_type_from_dict(): - test_get_entity_type(request_type=dict) - - def test_get_entity_type_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. @@ -1097,9 +1091,10 @@ async def test_get_entity_type_flattened_error_async(): ) -def test_create_entity_type( - transport: str = "grpc", request_type=gcd_entity_type.CreateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_entity_type.CreateEntityTypeRequest, dict,] +) +def test_create_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1139,10 +1134,6 @@ def test_create_entity_type( assert response.enable_fuzzy_extraction is True -def test_create_entity_type_from_dict(): - test_create_entity_type(request_type=dict) - - def test_create_entity_type_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. @@ -1364,9 +1355,10 @@ async def test_create_entity_type_flattened_error_async(): ) -def test_update_entity_type( - transport: str = "grpc", request_type=gcd_entity_type.UpdateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_entity_type.UpdateEntityTypeRequest, dict,] +) +def test_update_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1406,10 +1398,6 @@ def test_update_entity_type( assert response.enable_fuzzy_extraction is True -def test_update_entity_type_from_dict(): - test_update_entity_type(request_type=dict) - - def test_update_entity_type_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. @@ -1635,9 +1623,8 @@ async def test_update_entity_type_flattened_error_async(): ) -def test_delete_entity_type( - transport: str = "grpc", request_type=entity_type.DeleteEntityTypeRequest -): +@pytest.mark.parametrize("request_type", [entity_type.DeleteEntityTypeRequest, dict,]) +def test_delete_entity_type(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1663,10 +1650,6 @@ def test_delete_entity_type( assert response is None -def test_delete_entity_type_from_dict(): - test_delete_entity_type(request_type=dict) - - def test_delete_entity_type_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. @@ -1841,9 +1824,10 @@ async def test_delete_entity_type_flattened_error_async(): ) -def test_batch_update_entity_types( - transport: str = "grpc", request_type=entity_type.BatchUpdateEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchUpdateEntityTypesRequest, dict,] +) +def test_batch_update_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1869,10 +1853,6 @@ def test_batch_update_entity_types( assert isinstance(response, future.Future) -def test_batch_update_entity_types_from_dict(): - test_batch_update_entity_types(request_type=dict) - - def test_batch_update_entity_types_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. @@ -1982,9 +1962,10 @@ async def test_batch_update_entity_types_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_delete_entity_types( - transport: str = "grpc", request_type=entity_type.BatchDeleteEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchDeleteEntityTypesRequest, dict,] +) +def test_batch_delete_entity_types(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2010,10 +1991,6 @@ def test_batch_delete_entity_types( assert isinstance(response, future.Future) -def test_batch_delete_entity_types_from_dict(): - test_batch_delete_entity_types(request_type=dict) - - def test_batch_delete_entity_types_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. @@ -2209,9 +2186,10 @@ async def test_batch_delete_entity_types_flattened_error_async(): ) -def test_batch_create_entities( - transport: str = "grpc", request_type=entity_type.BatchCreateEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchCreateEntitiesRequest, dict,] +) +def test_batch_create_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2237,10 +2215,6 @@ def test_batch_create_entities( assert isinstance(response, future.Future) -def test_batch_create_entities_from_dict(): - test_batch_create_entities(request_type=dict) - - def test_batch_create_entities_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. @@ -2447,9 +2421,10 @@ async def test_batch_create_entities_flattened_error_async(): ) -def test_batch_update_entities( - transport: str = "grpc", request_type=entity_type.BatchUpdateEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchUpdateEntitiesRequest, dict,] +) +def test_batch_update_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2475,10 +2450,6 @@ def test_batch_update_entities( assert isinstance(response, future.Future) -def test_batch_update_entities_from_dict(): - test_batch_update_entities(request_type=dict) - - def test_batch_update_entities_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. @@ -2685,9 +2656,10 @@ async def test_batch_update_entities_flattened_error_async(): ) -def test_batch_delete_entities( - transport: str = "grpc", request_type=entity_type.BatchDeleteEntitiesRequest -): +@pytest.mark.parametrize( + "request_type", [entity_type.BatchDeleteEntitiesRequest, dict,] +) +def test_batch_delete_entities(request_type, transport: str = "grpc"): client = EntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2713,10 +2685,6 @@ def test_batch_delete_entities( assert isinstance(response, future.Future) -def test_batch_delete_entities_from_dict(): - test_batch_delete_entities(request_type=dict) - - def test_batch_delete_entities_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. @@ -3470,7 +3438,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/dialogflow_v2beta1/test_environments.py b/tests/unit/gapic/dialogflow_v2beta1/test_environments.py index 1c9635f21..7956a9c47 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_environments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_environments.py @@ -243,20 +243,20 @@ def test_environments_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, @@ -313,7 +313,7 @@ def test_environments_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 @@ -408,7 +408,7 @@ def test_environments_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, @@ -439,7 +439,7 @@ def test_environments_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", @@ -470,9 +470,8 @@ def test_environments_client_client_options_from_dict(): ) -def test_list_environments( - transport: str = "grpc", request_type=environment.ListEnvironmentsRequest -): +@pytest.mark.parametrize("request_type", [environment.ListEnvironmentsRequest, dict,]) +def test_list_environments(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -501,10 +500,6 @@ def test_list_environments( assert response.next_page_token == "next_page_token_value" -def test_list_environments_from_dict(): - test_list_environments(request_type=dict) - - def test_list_environments_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. @@ -688,8 +683,10 @@ async def test_list_environments_flattened_error_async(): ) -def test_list_environments_pager(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_environments_pager(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -730,8 +727,10 @@ def test_list_environments_pager(): assert all(isinstance(i, environment.Environment) for i in results) -def test_list_environments_pages(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_environments_pages(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -842,9 +841,8 @@ async def test_list_environments_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_environment( - transport: str = "grpc", request_type=environment.GetEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.GetEnvironmentRequest, dict,]) +def test_get_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -877,10 +875,6 @@ def test_get_environment( assert response.state == environment.Environment.State.STOPPED -def test_get_environment_from_dict(): - test_get_environment(request_type=dict) - - def test_get_environment_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. @@ -990,9 +984,8 @@ async def test_get_environment_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_environment( - transport: str = "grpc", request_type=environment.CreateEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.CreateEnvironmentRequest, dict,]) +def test_create_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1027,10 +1020,6 @@ def test_create_environment( assert response.state == environment.Environment.State.STOPPED -def test_create_environment_from_dict(): - test_create_environment(request_type=dict) - - def test_create_environment_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. @@ -1148,9 +1137,8 @@ async def test_create_environment_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_environment( - transport: str = "grpc", request_type=environment.UpdateEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.UpdateEnvironmentRequest, dict,]) +def test_update_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1185,10 +1173,6 @@ def test_update_environment( assert response.state == environment.Environment.State.STOPPED -def test_update_environment_from_dict(): - test_update_environment(request_type=dict) - - def test_update_environment_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. @@ -1310,9 +1294,8 @@ async def test_update_environment_field_headers_async(): ] -def test_delete_environment( - transport: str = "grpc", request_type=environment.DeleteEnvironmentRequest -): +@pytest.mark.parametrize("request_type", [environment.DeleteEnvironmentRequest, dict,]) +def test_delete_environment(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1338,10 +1321,6 @@ def test_delete_environment( assert response is None -def test_delete_environment_from_dict(): - test_delete_environment(request_type=dict) - - def test_delete_environment_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. @@ -1446,9 +1425,10 @@ async def test_delete_environment_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_environment_history( - transport: str = "grpc", request_type=environment.GetEnvironmentHistoryRequest -): +@pytest.mark.parametrize( + "request_type", [environment.GetEnvironmentHistoryRequest, dict,] +) +def test_get_environment_history(request_type, transport: str = "grpc"): client = EnvironmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1478,10 +1458,6 @@ def test_get_environment_history( assert response.next_page_token == "next_page_token_value" -def test_get_environment_history_from_dict(): - test_get_environment_history(request_type=dict) - - def test_get_environment_history_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. @@ -1595,8 +1571,10 @@ async def test_get_environment_history_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_environment_history_pager(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_get_environment_history_pager(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1639,8 +1617,10 @@ def test_get_environment_history_pager(): assert all(isinstance(i, environment.EnvironmentHistory.Entry) for i in results) -def test_get_environment_history_pages(): - client = EnvironmentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_get_environment_history_pages(transport_name: str = "grpc"): + client = EnvironmentsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2317,7 +2297,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/dialogflow_v2beta1/test_fulfillments.py b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py index d5aa85a73..608b83bc1 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_fulfillments.py @@ -240,20 +240,20 @@ def test_fulfillments_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, @@ -310,7 +310,7 @@ def test_fulfillments_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_fulfillments_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_fulfillments_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_fulfillments_client_client_options_from_dict(): ) -def test_get_fulfillment( - transport: str = "grpc", request_type=fulfillment.GetFulfillmentRequest -): +@pytest.mark.parametrize("request_type", [fulfillment.GetFulfillmentRequest, dict,]) +def test_get_fulfillment(request_type, transport: str = "grpc"): client = FulfillmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -503,10 +502,6 @@ def test_get_fulfillment( assert response.enabled is True -def test_get_fulfillment_from_dict(): - test_get_fulfillment(request_type=dict) - - def test_get_fulfillment_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. @@ -680,9 +675,10 @@ async def test_get_fulfillment_flattened_error_async(): ) -def test_update_fulfillment( - transport: str = "grpc", request_type=gcd_fulfillment.UpdateFulfillmentRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_fulfillment.UpdateFulfillmentRequest, dict,] +) +def test_update_fulfillment(request_type, transport: str = "grpc"): client = FulfillmentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -718,10 +714,6 @@ def test_update_fulfillment( assert response.enabled is True -def test_update_fulfillment_from_dict(): - test_update_fulfillment(request_type=dict) - - def test_update_fulfillment_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. @@ -1438,7 +1430,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/dialogflow_v2beta1/test_intents.py b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py index 1d09e6921..4b94b8a09 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_intents.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_intents.py @@ -232,20 +232,20 @@ def test_intents_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, @@ -300,7 +300,7 @@ def test_intents_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 @@ -391,7 +391,7 @@ def test_intents_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, @@ -418,7 +418,7 @@ def test_intents_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", @@ -449,7 +449,8 @@ def test_intents_client_client_options_from_dict(): ) -def test_list_intents(transport: str = "grpc", request_type=intent.ListIntentsRequest): +@pytest.mark.parametrize("request_type", [intent.ListIntentsRequest, dict,]) +def test_list_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -476,10 +477,6 @@ def test_list_intents(transport: str = "grpc", request_type=intent.ListIntentsRe assert response.next_page_token == "next_page_token_value" -def test_list_intents_from_dict(): - test_list_intents(request_type=dict) - - def test_list_intents_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. @@ -663,8 +660,10 @@ async def test_list_intents_flattened_error_async(): ) -def test_list_intents_pager(): - client = IntentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_intents_pager(transport_name: str = "grpc"): + client = IntentsClient( + 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_intents), "__call__") as call: @@ -695,8 +694,10 @@ def test_list_intents_pager(): assert all(isinstance(i, intent.Intent) for i in results) -def test_list_intents_pages(): - client = IntentsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_intents_pages(transport_name: str = "grpc"): + client = IntentsClient( + 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_intents), "__call__") as call: @@ -777,7 +778,8 @@ async def test_list_intents_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_intent(transport: str = "grpc", request_type=intent.GetIntentRequest): +@pytest.mark.parametrize("request_type", [intent.GetIntentRequest, dict,]) +def test_get_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -836,10 +838,6 @@ def test_get_intent(transport: str = "grpc", request_type=intent.GetIntentReques assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_get_intent_from_dict(): - test_get_intent(request_type=dict) - - def test_get_intent_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. @@ -1053,9 +1051,8 @@ async def test_get_intent_flattened_error_async(): ) -def test_create_intent( - transport: str = "grpc", request_type=gcd_intent.CreateIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_intent.CreateIntentRequest, dict,]) +def test_create_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1116,10 +1113,6 @@ def test_create_intent( assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_create_intent_from_dict(): - test_create_intent(request_type=dict) - - def test_create_intent_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. @@ -1349,9 +1342,8 @@ async def test_create_intent_flattened_error_async(): ) -def test_update_intent( - transport: str = "grpc", request_type=gcd_intent.UpdateIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_intent.UpdateIntentRequest, dict,]) +def test_update_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1412,10 +1404,6 @@ def test_update_intent( assert response.parent_followup_intent_name == "parent_followup_intent_name_value" -def test_update_intent_from_dict(): - test_update_intent(request_type=dict) - - def test_update_intent_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. @@ -1645,9 +1633,8 @@ async def test_update_intent_flattened_error_async(): ) -def test_delete_intent( - transport: str = "grpc", request_type=intent.DeleteIntentRequest -): +@pytest.mark.parametrize("request_type", [intent.DeleteIntentRequest, dict,]) +def test_delete_intent(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1671,10 +1658,6 @@ def test_delete_intent( assert response is None -def test_delete_intent_from_dict(): - test_delete_intent(request_type=dict) - - def test_delete_intent_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. @@ -1837,9 +1820,8 @@ async def test_delete_intent_flattened_error_async(): ) -def test_batch_update_intents( - transport: str = "grpc", request_type=intent.BatchUpdateIntentsRequest -): +@pytest.mark.parametrize("request_type", [intent.BatchUpdateIntentsRequest, dict,]) +def test_batch_update_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1865,10 +1847,6 @@ def test_batch_update_intents( assert isinstance(response, future.Future) -def test_batch_update_intents_from_dict(): - test_batch_update_intents(request_type=dict) - - def test_batch_update_intents_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. @@ -2077,9 +2055,8 @@ async def test_batch_update_intents_flattened_error_async(): ) -def test_batch_delete_intents( - transport: str = "grpc", request_type=intent.BatchDeleteIntentsRequest -): +@pytest.mark.parametrize("request_type", [intent.BatchDeleteIntentsRequest, dict,]) +def test_batch_delete_intents(request_type, transport: str = "grpc"): client = IntentsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2105,10 +2082,6 @@ def test_batch_delete_intents( assert isinstance(response, future.Future) -def test_batch_delete_intents_from_dict(): - test_batch_delete_intents(request_type=dict) - - def test_batch_delete_intents_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. @@ -2871,7 +2844,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/dialogflow_v2beta1/test_knowledge_bases.py b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py index 5d5e4c785..fac7f9fe8 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_knowledge_bases.py @@ -252,20 +252,20 @@ def test_knowledge_bases_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, @@ -324,7 +324,7 @@ def test_knowledge_bases_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 @@ -419,7 +419,7 @@ def test_knowledge_bases_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, @@ -450,7 +450,7 @@ def test_knowledge_bases_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", @@ -483,9 +483,10 @@ def test_knowledge_bases_client_client_options_from_dict(): ) -def test_list_knowledge_bases( - transport: str = "grpc", request_type=knowledge_base.ListKnowledgeBasesRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.ListKnowledgeBasesRequest, dict,] +) +def test_list_knowledge_bases(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -514,10 +515,6 @@ def test_list_knowledge_bases( assert response.next_page_token == "next_page_token_value" -def test_list_knowledge_bases_from_dict(): - test_list_knowledge_bases(request_type=dict) - - def test_list_knowledge_bases_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. @@ -708,8 +705,10 @@ async def test_list_knowledge_bases_flattened_error_async(): ) -def test_list_knowledge_bases_pager(): - client = KnowledgeBasesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_knowledge_bases_pager(transport_name: str = "grpc"): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -754,8 +753,10 @@ def test_list_knowledge_bases_pager(): assert all(isinstance(i, knowledge_base.KnowledgeBase) for i in results) -def test_list_knowledge_bases_pages(): - client = KnowledgeBasesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_knowledge_bases_pages(transport_name: str = "grpc"): + client = KnowledgeBasesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -878,9 +879,10 @@ async def test_list_knowledge_bases_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_knowledge_base( - transport: str = "grpc", request_type=knowledge_base.GetKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.GetKnowledgeBaseRequest, dict,] +) +def test_get_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -913,10 +915,6 @@ def test_get_knowledge_base( assert response.language_code == "language_code_value" -def test_get_knowledge_base_from_dict(): - test_get_knowledge_base(request_type=dict) - - def test_get_knowledge_base_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. @@ -1110,9 +1108,10 @@ async def test_get_knowledge_base_flattened_error_async(): ) -def test_create_knowledge_base( - transport: str = "grpc", request_type=gcd_knowledge_base.CreateKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_knowledge_base.CreateKnowledgeBaseRequest, dict,] +) +def test_create_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1145,10 +1144,6 @@ def test_create_knowledge_base( assert response.language_code == "language_code_value" -def test_create_knowledge_base_from_dict(): - test_create_knowledge_base(request_type=dict) - - def test_create_knowledge_base_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. @@ -1359,9 +1354,10 @@ async def test_create_knowledge_base_flattened_error_async(): ) -def test_delete_knowledge_base( - transport: str = "grpc", request_type=knowledge_base.DeleteKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [knowledge_base.DeleteKnowledgeBaseRequest, dict,] +) +def test_delete_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1387,10 +1383,6 @@ def test_delete_knowledge_base( assert response is None -def test_delete_knowledge_base_from_dict(): - test_delete_knowledge_base(request_type=dict) - - def test_delete_knowledge_base_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. @@ -1572,9 +1564,10 @@ async def test_delete_knowledge_base_flattened_error_async(): ) -def test_update_knowledge_base( - transport: str = "grpc", request_type=gcd_knowledge_base.UpdateKnowledgeBaseRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_knowledge_base.UpdateKnowledgeBaseRequest, dict,] +) +def test_update_knowledge_base(request_type, transport: str = "grpc"): client = KnowledgeBasesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1607,10 +1600,6 @@ def test_update_knowledge_base( assert response.language_code == "language_code_value" -def test_update_knowledge_base_from_dict(): - test_update_knowledge_base(request_type=dict) - - def test_update_knowledge_base_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. @@ -2355,7 +2344,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/dialogflow_v2beta1/test_participants.py b/tests/unit/gapic/dialogflow_v2beta1/test_participants.py index dc2bfbac6..847d3c0ff 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_participants.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_participants.py @@ -250,20 +250,20 @@ def test_participants_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, @@ -320,7 +320,7 @@ def test_participants_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 @@ -415,7 +415,7 @@ def test_participants_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, @@ -446,7 +446,7 @@ def test_participants_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", @@ -477,9 +477,10 @@ def test_participants_client_client_options_from_dict(): ) -def test_create_participant( - transport: str = "grpc", request_type=gcd_participant.CreateParticipantRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_participant.CreateParticipantRequest, dict,] +) +def test_create_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -512,10 +513,6 @@ def test_create_participant( assert response.obfuscated_external_user_id == "obfuscated_external_user_id_value" -def test_create_participant_from_dict(): - test_create_participant(request_type=dict) - - def test_create_participant_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. @@ -720,9 +717,8 @@ async def test_create_participant_flattened_error_async(): ) -def test_get_participant( - transport: str = "grpc", request_type=participant.GetParticipantRequest -): +@pytest.mark.parametrize("request_type", [participant.GetParticipantRequest, dict,]) +def test_get_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -753,10 +749,6 @@ def test_get_participant( assert response.obfuscated_external_user_id == "obfuscated_external_user_id_value" -def test_get_participant_from_dict(): - test_get_participant(request_type=dict) - - def test_get_participant_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. @@ -932,9 +924,8 @@ async def test_get_participant_flattened_error_async(): ) -def test_list_participants( - transport: str = "grpc", request_type=participant.ListParticipantsRequest -): +@pytest.mark.parametrize("request_type", [participant.ListParticipantsRequest, dict,]) +def test_list_participants(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -963,10 +954,6 @@ def test_list_participants( assert response.next_page_token == "next_page_token_value" -def test_list_participants_from_dict(): - test_list_participants(request_type=dict) - - def test_list_participants_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. @@ -1150,8 +1137,10 @@ async def test_list_participants_flattened_error_async(): ) -def test_list_participants_pager(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_participants_pager(transport_name: str = "grpc"): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1192,8 +1181,10 @@ def test_list_participants_pager(): assert all(isinstance(i, participant.Participant) for i in results) -def test_list_participants_pages(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_participants_pages(transport_name: str = "grpc"): + client = ParticipantsClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1304,9 +1295,10 @@ async def test_list_participants_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_participant( - transport: str = "grpc", request_type=gcd_participant.UpdateParticipantRequest -): +@pytest.mark.parametrize( + "request_type", [gcd_participant.UpdateParticipantRequest, dict,] +) +def test_update_participant(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1339,10 +1331,6 @@ def test_update_participant( assert response.obfuscated_external_user_id == "obfuscated_external_user_id_value" -def test_update_participant_from_dict(): - test_update_participant(request_type=dict) - - def test_update_participant_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. @@ -1551,9 +1539,8 @@ async def test_update_participant_flattened_error_async(): ) -def test_analyze_content( - transport: str = "grpc", request_type=gcd_participant.AnalyzeContentRequest -): +@pytest.mark.parametrize("request_type", [gcd_participant.AnalyzeContentRequest, dict,]) +def test_analyze_content(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1580,10 +1567,6 @@ def test_analyze_content( assert response.reply_text == "reply_text_value" -def test_analyze_content_from_dict(): - test_analyze_content(request_type=dict) - - def test_analyze_content_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. @@ -1769,9 +1752,8 @@ async def test_analyze_content_flattened_error_async(): ) -def test_suggest_articles( - transport: str = "grpc", request_type=participant.SuggestArticlesRequest -): +@pytest.mark.parametrize("request_type", [participant.SuggestArticlesRequest, dict,]) +def test_suggest_articles(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1799,10 +1781,6 @@ def test_suggest_articles( assert response.context_size == 1311 -def test_suggest_articles_from_dict(): - test_suggest_articles(request_type=dict) - - def test_suggest_articles_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. @@ -1975,9 +1953,8 @@ async def test_suggest_articles_flattened_error_async(): ) -def test_suggest_faq_answers( - transport: str = "grpc", request_type=participant.SuggestFaqAnswersRequest -): +@pytest.mark.parametrize("request_type", [participant.SuggestFaqAnswersRequest, dict,]) +def test_suggest_faq_answers(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2007,10 +1984,6 @@ def test_suggest_faq_answers( assert response.context_size == 1311 -def test_suggest_faq_answers_from_dict(): - test_suggest_faq_answers(request_type=dict) - - def test_suggest_faq_answers_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. @@ -2195,9 +2168,10 @@ async def test_suggest_faq_answers_flattened_error_async(): ) -def test_suggest_smart_replies( - transport: str = "grpc", request_type=participant.SuggestSmartRepliesRequest -): +@pytest.mark.parametrize( + "request_type", [participant.SuggestSmartRepliesRequest, dict,] +) +def test_suggest_smart_replies(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2227,10 +2201,6 @@ def test_suggest_smart_replies( assert response.context_size == 1311 -def test_suggest_smart_replies_from_dict(): - test_suggest_smart_replies(request_type=dict) - - def test_suggest_smart_replies_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. @@ -2415,9 +2385,8 @@ async def test_suggest_smart_replies_flattened_error_async(): ) -def test_list_suggestions( - transport: str = "grpc", request_type=participant.ListSuggestionsRequest -): +@pytest.mark.parametrize("request_type", [participant.ListSuggestionsRequest, dict,]) +def test_list_suggestions(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2444,10 +2413,6 @@ def test_list_suggestions( assert response.next_page_token == "next_page_token_value" -def test_list_suggestions_from_dict(): - test_list_suggestions(request_type=dict) - - def test_list_suggestions_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. @@ -2551,8 +2516,10 @@ async def test_list_suggestions_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_suggestions_pager(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_suggestions_pager(transport_name: str = "grpc"): + client = ParticipantsClient( + 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_suggestions), "__call__") as call: @@ -2589,8 +2556,10 @@ def test_list_suggestions_pager(): assert all(isinstance(i, participant.Suggestion) for i in results) -def test_list_suggestions_pages(): - client = ParticipantsClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_suggestions_pages(transport_name: str = "grpc"): + client = ParticipantsClient( + 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_suggestions), "__call__") as call: @@ -2689,9 +2658,8 @@ async def test_list_suggestions_async_pages(): assert page_.raw_page.next_page_token == token -def test_compile_suggestion( - transport: str = "grpc", request_type=participant.CompileSuggestionRequest -): +@pytest.mark.parametrize("request_type", [participant.CompileSuggestionRequest, dict,]) +def test_compile_suggestion(request_type, transport: str = "grpc"): client = ParticipantsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2721,10 +2689,6 @@ def test_compile_suggestion( assert response.context_size == 1311 -def test_compile_suggestion_from_dict(): - test_compile_suggestion(request_type=dict) - - def test_compile_suggestion_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. @@ -3479,7 +3443,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/dialogflow_v2beta1/test_session_entity_types.py b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py index 421b212a9..e91158936 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_session_entity_types.py @@ -256,20 +256,20 @@ def test_session_entity_types_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, @@ -338,7 +338,7 @@ def test_session_entity_types_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 @@ -433,7 +433,7 @@ def test_session_entity_types_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, @@ -464,7 +464,7 @@ def test_session_entity_types_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", @@ -497,10 +497,10 @@ def test_session_entity_types_client_client_options_from_dict(): ) -def test_list_session_entity_types( - transport: str = "grpc", - request_type=session_entity_type.ListSessionEntityTypesRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.ListSessionEntityTypesRequest, dict,] +) +def test_list_session_entity_types(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -529,10 +529,6 @@ def test_list_session_entity_types( assert response.next_page_token == "next_page_token_value" -def test_list_session_entity_types_from_dict(): - test_list_session_entity_types(request_type=dict) - - def test_list_session_entity_types_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. @@ -729,8 +725,10 @@ async def test_list_session_entity_types_flattened_error_async(): ) -def test_list_session_entity_types_pager(): - client = SessionEntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_session_entity_types_pager(transport_name: str = "grpc"): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -777,8 +775,10 @@ def test_list_session_entity_types_pager(): ) -def test_list_session_entity_types_pages(): - client = SessionEntityTypesClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_session_entity_types_pages(transport_name: str = "grpc"): + client = SessionEntityTypesClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -907,10 +907,10 @@ async def test_list_session_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_session_entity_type( - transport: str = "grpc", - request_type=session_entity_type.GetSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.GetSessionEntityTypeRequest, dict,] +) +def test_get_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -944,10 +944,6 @@ def test_get_session_entity_type( ) -def test_get_session_entity_type_from_dict(): - test_get_session_entity_type(request_type=dict) - - def test_get_session_entity_type_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. @@ -1149,10 +1145,10 @@ async def test_get_session_entity_type_flattened_error_async(): ) -def test_create_session_entity_type( - transport: str = "grpc", - request_type=gcd_session_entity_type.CreateSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_session_entity_type.CreateSessionEntityTypeRequest, dict,] +) +def test_create_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1186,10 +1182,6 @@ def test_create_session_entity_type( ) -def test_create_session_entity_type_from_dict(): - test_create_session_entity_type(request_type=dict) - - def test_create_session_entity_type_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. @@ -1415,10 +1407,10 @@ async def test_create_session_entity_type_flattened_error_async(): ) -def test_update_session_entity_type( - transport: str = "grpc", - request_type=gcd_session_entity_type.UpdateSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [gcd_session_entity_type.UpdateSessionEntityTypeRequest, dict,] +) +def test_update_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1452,10 +1444,6 @@ def test_update_session_entity_type( ) -def test_update_session_entity_type_from_dict(): - test_update_session_entity_type(request_type=dict) - - def test_update_session_entity_type_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. @@ -1687,10 +1675,10 @@ async def test_update_session_entity_type_flattened_error_async(): ) -def test_delete_session_entity_type( - transport: str = "grpc", - request_type=session_entity_type.DeleteSessionEntityTypeRequest, -): +@pytest.mark.parametrize( + "request_type", [session_entity_type.DeleteSessionEntityTypeRequest, dict,] +) +def test_delete_session_entity_type(request_type, transport: str = "grpc"): client = SessionEntityTypesClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1716,10 +1704,6 @@ def test_delete_session_entity_type( assert response is None -def test_delete_session_entity_type_from_dict(): - test_delete_session_entity_type(request_type=dict) - - def test_delete_session_entity_type_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. @@ -2443,7 +2427,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/dialogflow_v2beta1/test_sessions.py b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py index 0095c44db..aa54c83dd 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_sessions.py @@ -238,20 +238,20 @@ def test_sessions_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, @@ -308,7 +308,7 @@ def test_sessions_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 @@ -399,7 +399,7 @@ def test_sessions_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, @@ -426,7 +426,7 @@ def test_sessions_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", @@ -457,9 +457,8 @@ def test_sessions_client_client_options_from_dict(): ) -def test_detect_intent( - transport: str = "grpc", request_type=gcd_session.DetectIntentRequest -): +@pytest.mark.parametrize("request_type", [gcd_session.DetectIntentRequest, dict,]) +def test_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -487,10 +486,6 @@ def test_detect_intent( assert response.output_audio == b"output_audio_blob" -def test_detect_intent_from_dict(): - test_detect_intent(request_type=dict) - - def test_detect_intent_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. @@ -703,9 +698,8 @@ async def test_detect_intent_flattened_error_async(): ) -def test_streaming_detect_intent( - transport: str = "grpc", request_type=session.StreamingDetectIntentRequest -): +@pytest.mark.parametrize("request_type", [session.StreamingDetectIntentRequest, dict,]) +def test_streaming_detect_intent(request_type, transport: str = "grpc"): client = SessionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -733,10 +727,6 @@ def test_streaming_detect_intent( assert isinstance(message, session.StreamingDetectIntentResponse) -def test_streaming_detect_intent_from_dict(): - test_streaming_detect_intent(request_type=dict) - - @pytest.mark.asyncio async def test_streaming_detect_intent_async( transport: str = "grpc_asyncio", request_type=session.StreamingDetectIntentRequest @@ -1378,7 +1368,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/dialogflow_v2beta1/test_versions.py b/tests/unit/gapic/dialogflow_v2beta1/test_versions.py index a4fa212bf..2e20752cd 100644 --- a/tests/unit/gapic/dialogflow_v2beta1/test_versions.py +++ b/tests/unit/gapic/dialogflow_v2beta1/test_versions.py @@ -232,20 +232,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, @@ -302,7 +302,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 @@ -393,7 +393,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, @@ -420,7 +420,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", @@ -451,9 +451,8 @@ def test_versions_client_client_options_from_dict(): ) -def test_list_versions( - transport: str = "grpc", request_type=version.ListVersionsRequest -): +@pytest.mark.parametrize("request_type", [version.ListVersionsRequest, dict,]) +def test_list_versions(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -480,10 +479,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. @@ -653,8 +648,10 @@ async def test_list_versions_flattened_error_async(): ) -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: @@ -687,8 +684,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: @@ -775,7 +774,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=version.GetVersionRequest): +@pytest.mark.parametrize("request_type", [version.GetVersionRequest, dict,]) +def test_get_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -808,10 +808,6 @@ def test_get_version(transport: str = "grpc", request_type=version.GetVersionReq assert response.status == version.Version.VersionStatus.IN_PROGRESS -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. @@ -985,9 +981,8 @@ async def test_get_version_flattened_error_async(): ) -def test_create_version( - transport: str = "grpc", request_type=gcd_version.CreateVersionRequest -): +@pytest.mark.parametrize("request_type", [gcd_version.CreateVersionRequest, dict,]) +def test_create_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1020,10 +1015,6 @@ def test_create_version( assert response.status == gcd_version.Version.VersionStatus.IN_PROGRESS -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. @@ -1211,9 +1202,8 @@ async def test_create_version_flattened_error_async(): ) -def test_update_version( - transport: str = "grpc", request_type=gcd_version.UpdateVersionRequest -): +@pytest.mark.parametrize("request_type", [gcd_version.UpdateVersionRequest, dict,]) +def test_update_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1246,10 +1236,6 @@ def test_update_version( assert response.status == gcd_version.Version.VersionStatus.IN_PROGRESS -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. @@ -1443,9 +1429,8 @@ async def test_update_version_flattened_error_async(): ) -def test_delete_version( - transport: str = "grpc", request_type=version.DeleteVersionRequest -): +@pytest.mark.parametrize("request_type", [version.DeleteVersionRequest, dict,]) +def test_delete_version(request_type, transport: str = "grpc"): client = VersionsClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1469,10 +1454,6 @@ def test_delete_version( assert response is None -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. @@ -2146,7 +2127,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(