diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py index 86eb401885..0235c7dbd3 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/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/aiplatform_v1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py index b523932066..2e684a1b69 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/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/aiplatform_v1/services/featurestore_online_serving_service/transports/base.py b/google/cloud/aiplatform_v1/services/featurestore_online_serving_service/transports/base.py index 88e5a03c54..281cdc5ae9 100644 --- a/google/cloud/aiplatform_v1/services/featurestore_online_serving_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/featurestore_online_serving_service/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1/services/featurestore_service/transports/base.py b/google/cloud/aiplatform_v1/services/featurestore_service/transports/base.py index f4f71d58c9..58ce81dd4a 100644 --- a/google/cloud/aiplatform_v1/services/featurestore_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/featurestore_service/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/aiplatform_v1/services/index_endpoint_service/transports/base.py b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py index 094ccb33c8..2363e8864b 100644 --- a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/index_endpoint_service/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/aiplatform_v1/services/index_service/transports/base.py b/google/cloud/aiplatform_v1/services/index_service/transports/base.py index c6d5eded3b..52aad2799c 100644 --- a/google/cloud/aiplatform_v1/services/index_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/index_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1/services/job_service/transports/base.py index e94b170248..fd11d859f3 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/base.py @@ -120,7 +120,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/aiplatform_v1/services/metadata_service/transports/base.py b/google/cloud/aiplatform_v1/services/metadata_service/transports/base.py index 1680f3f1f9..b1c0e63177 100644 --- a/google/cloud/aiplatform_v1/services/metadata_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/metadata_service/transports/base.py @@ -113,7 +113,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/aiplatform_v1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py index 147276408a..4eee97b2ac 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py @@ -103,7 +103,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/aiplatform_v1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1/services/model_service/transports/base.py index 5615336d38..bf146699d0 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/model_service/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/aiplatform_v1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py index 3da341fbb7..b61c52dda0 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/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/aiplatform_v1/services/prediction_service/client.py b/google/cloud/aiplatform_v1/services/prediction_service/client.py index e3cb2c5a53..07834c79d6 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/client.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/client.py @@ -390,7 +390,7 @@ def predict( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> prediction_service.PredictResponse: - """Perform an online prediction. + r"""Perform an online prediction. Args: request (Union[google.cloud.aiplatform_v1.types.PredictRequest, dict]): @@ -494,7 +494,7 @@ def raw_predict( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> httpbody_pb2.HttpBody: - """Perform an online prediction with an arbitrary HTTP payload. + r"""Perform an online prediction with an arbitrary HTTP payload. The response includes the following HTTP headers: @@ -651,7 +651,7 @@ def explain( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> prediction_service.ExplainResponse: - """Perform an online explanation. + r"""Perform an online explanation. If [deployed_model_id][google.cloud.aiplatform.v1.ExplainRequest.deployed_model_id] diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py index 4a1d1706f3..eba0aa22f7 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py @@ -102,7 +102,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/aiplatform_v1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py index 86f7871a6f..74eb77b6ce 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1/services/tensorboard_service/transports/base.py b/google/cloud/aiplatform_v1/services/tensorboard_service/transports/base.py index af7f8f6d7a..a13a7638db 100644 --- a/google/cloud/aiplatform_v1/services/tensorboard_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/tensorboard_service/transports/base.py @@ -117,7 +117,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/aiplatform_v1/services/vizier_service/transports/base.py b/google/cloud/aiplatform_v1/services/vizier_service/transports/base.py index a31cdaf9ff..80033df1ee 100644 --- a/google/cloud/aiplatform_v1/services/vizier_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/vizier_service/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/aiplatform_v1beta1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py index 50109d924a..4efd26a64d 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/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/aiplatform_v1beta1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py index 31126b6a54..90302bcbb7 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/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/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py index 5ecb44843f..7d775e8d43 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py index eb86454877..4c6c697cbd 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/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/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py index 729e32879b..cdf3473da1 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/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/aiplatform_v1beta1/services/index_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py index cfb9266121..4c99f59854 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py index 75f1226267..e5f24d7f13 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py @@ -122,7 +122,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/aiplatform_v1beta1/services/metadata_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py index d2ceb126be..64e5528bde 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py @@ -113,7 +113,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/aiplatform_v1beta1/services/migration_service/client.py b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py index 5463d3db1c..934c31c91e 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py @@ -183,32 +183,32 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def dataset_path(project: str, location: str, dataset: str,) -> str: + def dataset_path(project: str, dataset: str,) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/locations/{location}/datasets/{dataset}".format( - project=project, location=location, dataset=dataset, + return "projects/{project}/datasets/{dataset}".format( + project=project, dataset=dataset, ) @staticmethod def parse_dataset_path(path: str) -> Dict[str, str]: """Parses a dataset path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/datasets/(?P.+?)$", - path, - ) + m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def dataset_path(project: str, dataset: str,) -> str: + def dataset_path(project: str, location: str, dataset: str,) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, + return "projects/{project}/locations/{location}/datasets/{dataset}".format( + project=project, location=location, dataset=dataset, ) @staticmethod def parse_dataset_path(path: str) -> Dict[str, str]: """Parses a dataset path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/datasets/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py index 5557f97a46..b945690ed9 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py @@ -103,7 +103,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/aiplatform_v1beta1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py index fa0da90bf0..0e9c8503f7 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/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/aiplatform_v1beta1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py index 3c1512e2cd..cb061f614f 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py @@ -110,7 +110,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/aiplatform_v1beta1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py index 8ea55559e6..c58c155c89 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py @@ -102,7 +102,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/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py index 521dade561..3cf9d59e6a 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py @@ -104,7 +104,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py index 96c05a9bcc..f5d7a689ed 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py @@ -114,7 +114,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/aiplatform_v1beta1/services/vizier_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py index f52d925d28..a15615bc0c 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/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/aiplatform_v1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py index f329e5dd81..ae4e00c3b5 100644 --- a/tests/unit/gapic/aiplatform_v1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py @@ -263,20 +263,20 @@ def test_dataset_service_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, @@ -335,7 +335,7 @@ def test_dataset_service_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 @@ -430,7 +430,7 @@ def test_dataset_service_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, @@ -461,7 +461,7 @@ def test_dataset_service_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", @@ -494,9 +494,8 @@ def test_dataset_service_client_client_options_from_dict(): ) -def test_create_dataset( - transport: str = "grpc", request_type=dataset_service.CreateDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.CreateDatasetRequest, dict,]) +def test_create_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -520,10 +519,6 @@ def test_create_dataset( assert isinstance(response, future.Future) -def test_create_dataset_from_dict(): - test_create_dataset(request_type=dict) - - def test_create_dataset_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. @@ -712,9 +707,8 @@ async def test_create_dataset_flattened_error_async(): ) -def test_get_dataset( - transport: str = "grpc", request_type=dataset_service.GetDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.GetDatasetRequest, dict,]) +def test_get_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -749,10 +743,6 @@ def test_get_dataset( assert response.etag == "etag_value" -def test_get_dataset_from_dict(): - test_get_dataset(request_type=dict) - - def test_get_dataset_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. @@ -934,9 +924,8 @@ async def test_get_dataset_flattened_error_async(): ) -def test_update_dataset( - transport: str = "grpc", request_type=dataset_service.UpdateDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.UpdateDatasetRequest, dict,]) +def test_update_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -971,10 +960,6 @@ def test_update_dataset( assert response.etag == "etag_value" -def test_update_dataset_from_dict(): - test_update_dataset(request_type=dict) - - def test_update_dataset_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. @@ -1176,9 +1161,8 @@ async def test_update_dataset_flattened_error_async(): ) -def test_list_datasets( - transport: str = "grpc", request_type=dataset_service.ListDatasetsRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ListDatasetsRequest, dict,]) +def test_list_datasets(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1205,10 +1189,6 @@ def test_list_datasets( assert response.next_page_token == "next_page_token_value" -def test_list_datasets_from_dict(): - test_list_datasets(request_type=dict) - - def test_list_datasets_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. @@ -1386,8 +1366,10 @@ async def test_list_datasets_flattened_error_async(): ) -def test_list_datasets_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_datasets_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_datasets), "__call__") as call: @@ -1420,8 +1402,10 @@ def test_list_datasets_pager(): assert all(isinstance(i, dataset.Dataset) for i in results) -def test_list_datasets_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_datasets_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_datasets), "__call__") as call: @@ -1508,9 +1492,8 @@ async def test_list_datasets_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_dataset( - transport: str = "grpc", request_type=dataset_service.DeleteDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.DeleteDatasetRequest, dict,]) +def test_delete_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1534,10 +1517,6 @@ def test_delete_dataset( assert isinstance(response, future.Future) -def test_delete_dataset_from_dict(): - test_delete_dataset(request_type=dict) - - def test_delete_dataset_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. @@ -1712,9 +1691,8 @@ async def test_delete_dataset_flattened_error_async(): ) -def test_import_data( - transport: str = "grpc", request_type=dataset_service.ImportDataRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ImportDataRequest, dict,]) +def test_import_data(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1738,10 +1716,6 @@ def test_import_data( assert isinstance(response, future.Future) -def test_import_data_from_dict(): - test_import_data(request_type=dict) - - def test_import_data_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. @@ -1944,9 +1918,8 @@ async def test_import_data_flattened_error_async(): ) -def test_export_data( - transport: str = "grpc", request_type=dataset_service.ExportDataRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ExportDataRequest, dict,]) +def test_export_data(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1970,10 +1943,6 @@ def test_export_data( assert isinstance(response, future.Future) -def test_export_data_from_dict(): - test_export_data(request_type=dict) - - def test_export_data_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. @@ -2188,9 +2157,8 @@ async def test_export_data_flattened_error_async(): ) -def test_list_data_items( - transport: str = "grpc", request_type=dataset_service.ListDataItemsRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ListDataItemsRequest, dict,]) +def test_list_data_items(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2217,10 +2185,6 @@ def test_list_data_items( assert response.next_page_token == "next_page_token_value" -def test_list_data_items_from_dict(): - test_list_data_items(request_type=dict) - - def test_list_data_items_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. @@ -2398,8 +2362,10 @@ async def test_list_data_items_flattened_error_async(): ) -def test_list_data_items_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_items_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_data_items), "__call__") as call: @@ -2438,8 +2404,10 @@ def test_list_data_items_pager(): assert all(isinstance(i, data_item.DataItem) for i in results) -def test_list_data_items_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_items_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_data_items), "__call__") as call: @@ -2544,9 +2512,10 @@ async def test_list_data_items_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_annotation_spec( - transport: str = "grpc", request_type=dataset_service.GetAnnotationSpecRequest -): +@pytest.mark.parametrize( + "request_type", [dataset_service.GetAnnotationSpecRequest, dict,] +) +def test_get_annotation_spec(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2577,10 +2546,6 @@ def test_get_annotation_spec( assert response.etag == "etag_value" -def test_get_annotation_spec_from_dict(): - test_get_annotation_spec(request_type=dict) - - def test_get_annotation_spec_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. @@ -2773,9 +2738,10 @@ async def test_get_annotation_spec_flattened_error_async(): ) -def test_list_annotations( - transport: str = "grpc", request_type=dataset_service.ListAnnotationsRequest -): +@pytest.mark.parametrize( + "request_type", [dataset_service.ListAnnotationsRequest, dict,] +) +def test_list_annotations(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2802,10 +2768,6 @@ def test_list_annotations( assert response.next_page_token == "next_page_token_value" -def test_list_annotations_from_dict(): - test_list_annotations(request_type=dict) - - def test_list_annotations_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. @@ -2983,8 +2945,10 @@ async def test_list_annotations_flattened_error_async(): ) -def test_list_annotations_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_annotations_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_annotations), "__call__") as call: @@ -3023,8 +2987,10 @@ def test_list_annotations_pager(): assert all(isinstance(i, annotation.Annotation) for i in results) -def test_list_annotations_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_annotations_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_annotations), "__call__") as call: @@ -3774,7 +3740,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/aiplatform_v1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py index 3b92c2af95..d878bdc500 100644 --- a/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py @@ -263,20 +263,20 @@ def test_endpoint_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -345,7 +345,7 @@ def test_endpoint_service_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 @@ -440,7 +440,7 @@ def test_endpoint_service_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, @@ -471,7 +471,7 @@ def test_endpoint_service_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", @@ -504,9 +504,10 @@ def test_endpoint_service_client_client_options_from_dict(): ) -def test_create_endpoint( - transport: str = "grpc", request_type=endpoint_service.CreateEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.CreateEndpointRequest, dict,] +) +def test_create_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -530,10 +531,6 @@ def test_create_endpoint( assert isinstance(response, future.Future) -def test_create_endpoint_from_dict(): - test_create_endpoint(request_type=dict) - - def test_create_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -734,9 +731,8 @@ async def test_create_endpoint_flattened_error_async(): ) -def test_get_endpoint( - transport: str = "grpc", request_type=endpoint_service.GetEndpointRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.GetEndpointRequest, dict,]) +def test_get_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -778,10 +774,6 @@ def test_get_endpoint( ) -def test_get_endpoint_from_dict(): - test_get_endpoint(request_type=dict) - - def test_get_endpoint_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. @@ -970,9 +962,8 @@ async def test_get_endpoint_flattened_error_async(): ) -def test_list_endpoints( - transport: str = "grpc", request_type=endpoint_service.ListEndpointsRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.ListEndpointsRequest, dict,]) +def test_list_endpoints(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -999,10 +990,6 @@ def test_list_endpoints( assert response.next_page_token == "next_page_token_value" -def test_list_endpoints_from_dict(): - test_list_endpoints(request_type=dict) - - def test_list_endpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1180,8 +1167,10 @@ async def test_list_endpoints_flattened_error_async(): ) -def test_list_endpoints_pager(): - client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pager(transport_name: str = "grpc"): + client = EndpointServiceClient( + 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_endpoints), "__call__") as call: @@ -1220,8 +1209,10 @@ def test_list_endpoints_pager(): assert all(isinstance(i, endpoint.Endpoint) for i in results) -def test_list_endpoints_pages(): - client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pages(transport_name: str = "grpc"): + client = EndpointServiceClient( + 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_endpoints), "__call__") as call: @@ -1330,9 +1321,10 @@ async def test_list_endpoints_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_endpoint( - transport: str = "grpc", request_type=endpoint_service.UpdateEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.UpdateEndpointRequest, dict,] +) +def test_update_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1374,10 +1366,6 @@ def test_update_endpoint( ) -def test_update_endpoint_from_dict(): - test_update_endpoint(request_type=dict) - - def test_update_endpoint_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. @@ -1590,9 +1578,10 @@ async def test_update_endpoint_flattened_error_async(): ) -def test_delete_endpoint( - transport: str = "grpc", request_type=endpoint_service.DeleteEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.DeleteEndpointRequest, dict,] +) +def test_delete_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1616,10 +1605,6 @@ def test_delete_endpoint( assert isinstance(response, future.Future) -def test_delete_endpoint_from_dict(): - test_delete_endpoint(request_type=dict) - - def test_delete_endpoint_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,9 +1779,8 @@ async def test_delete_endpoint_flattened_error_async(): ) -def test_deploy_model( - transport: str = "grpc", request_type=endpoint_service.DeployModelRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.DeployModelRequest, dict,]) +def test_deploy_model(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1820,10 +1804,6 @@ def test_deploy_model( assert isinstance(response, future.Future) -def test_deploy_model_from_dict(): - test_deploy_model(request_type=dict) - - def test_deploy_model_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. @@ -2060,9 +2040,8 @@ async def test_deploy_model_flattened_error_async(): ) -def test_undeploy_model( - transport: str = "grpc", request_type=endpoint_service.UndeployModelRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.UndeployModelRequest, dict,]) +def test_undeploy_model(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2086,10 +2065,6 @@ def test_undeploy_model( assert isinstance(response, future.Future) -def test_undeploy_model_from_dict(): - test_undeploy_model(request_type=dict) - - def test_undeploy_model_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. @@ -2915,7 +2890,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/aiplatform_v1/test_featurestore_online_serving_service.py b/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py index 2a5deb4265..ad57291ff3 100644 --- a/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py @@ -284,20 +284,20 @@ def test_featurestore_online_serving_service_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, @@ -366,7 +366,7 @@ def test_featurestore_online_serving_service_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 @@ -465,7 +465,7 @@ def test_featurestore_online_serving_service_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, @@ -500,7 +500,7 @@ def test_featurestore_online_serving_service_client_client_options_credentials_f 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", @@ -533,10 +533,10 @@ def test_featurestore_online_serving_service_client_client_options_from_dict(): ) -def test_read_feature_values( - transport: str = "grpc", - request_type=featurestore_online_service.ReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_online_service.ReadFeatureValuesRequest, dict,] +) +def test_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreOnlineServingServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -562,10 +562,6 @@ def test_read_feature_values( assert isinstance(response, featurestore_online_service.ReadFeatureValuesResponse) -def test_read_feature_values_from_dict(): - test_read_feature_values(request_type=dict) - - def test_read_feature_values_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. @@ -761,10 +757,11 @@ async def test_read_feature_values_flattened_error_async(): ) -def test_streaming_read_feature_values( - transport: str = "grpc", - request_type=featurestore_online_service.StreamingReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", + [featurestore_online_service.StreamingReadFeatureValuesRequest, dict,], +) +def test_streaming_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreOnlineServingServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -797,10 +794,6 @@ def test_streaming_read_feature_values( ) -def test_streaming_read_feature_values_from_dict(): - test_streaming_read_feature_values(request_type=dict) - - def test_streaming_read_feature_values_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. @@ -1554,7 +1547,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/aiplatform_v1/test_featurestore_service.py b/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py index 90402f0bcd..12365b7183 100644 --- a/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py @@ -271,20 +271,20 @@ def test_featurestore_service_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, @@ -353,7 +353,7 @@ def test_featurestore_service_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 @@ -452,7 +452,7 @@ def test_featurestore_service_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, @@ -487,7 +487,7 @@ def test_featurestore_service_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", @@ -520,9 +520,10 @@ def test_featurestore_service_client_client_options_from_dict(): ) -def test_create_featurestore( - transport: str = "grpc", request_type=featurestore_service.CreateFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateFeaturestoreRequest, dict,] +) +def test_create_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -548,10 +549,6 @@ def test_create_featurestore( assert isinstance(response, future.Future) -def test_create_featurestore_from_dict(): - test_create_featurestore(request_type=dict) - - def test_create_featurestore_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. @@ -771,9 +768,10 @@ async def test_create_featurestore_flattened_error_async(): ) -def test_get_featurestore( - transport: str = "grpc", request_type=featurestore_service.GetFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetFeaturestoreRequest, dict,] +) +def test_get_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -804,10 +802,6 @@ def test_get_featurestore( assert response.state == featurestore.Featurestore.State.STABLE -def test_get_featurestore_from_dict(): - test_get_featurestore(request_type=dict) - - def test_get_featurestore_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. @@ -996,9 +990,10 @@ async def test_get_featurestore_flattened_error_async(): ) -def test_list_featurestores( - transport: str = "grpc", request_type=featurestore_service.ListFeaturestoresRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListFeaturestoresRequest, dict,] +) +def test_list_featurestores(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1027,10 +1022,6 @@ def test_list_featurestores( assert response.next_page_token == "next_page_token_value" -def test_list_featurestores_from_dict(): - test_list_featurestores(request_type=dict) - - def test_list_featurestores_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. @@ -1227,8 +1218,10 @@ async def test_list_featurestores_flattened_error_async(): ) -def test_list_featurestores_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_featurestores_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1272,8 +1265,10 @@ def test_list_featurestores_pager(): assert all(isinstance(i, featurestore.Featurestore) for i in results) -def test_list_featurestores_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_featurestores_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1397,9 +1392,10 @@ async def test_list_featurestores_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_featurestore( - transport: str = "grpc", request_type=featurestore_service.UpdateFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateFeaturestoreRequest, dict,] +) +def test_update_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1425,10 +1421,6 @@ def test_update_featurestore( assert isinstance(response, future.Future) -def test_update_featurestore_from_dict(): - test_update_featurestore(request_type=dict) - - def test_update_featurestore_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. @@ -1644,9 +1636,10 @@ async def test_update_featurestore_flattened_error_async(): ) -def test_delete_featurestore( - transport: str = "grpc", request_type=featurestore_service.DeleteFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteFeaturestoreRequest, dict,] +) +def test_delete_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1672,10 +1665,6 @@ def test_delete_featurestore( assert isinstance(response, future.Future) -def test_delete_featurestore_from_dict(): - test_delete_featurestore(request_type=dict) - - def test_delete_featurestore_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. @@ -1881,9 +1870,10 @@ async def test_delete_featurestore_flattened_error_async(): ) -def test_create_entity_type( - transport: str = "grpc", request_type=featurestore_service.CreateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateEntityTypeRequest, dict,] +) +def test_create_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1909,10 +1899,6 @@ def test_create_entity_type( assert isinstance(response, future.Future) -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. @@ -2132,9 +2118,10 @@ async def test_create_entity_type_flattened_error_async(): ) -def test_get_entity_type( - transport: str = "grpc", request_type=featurestore_service.GetEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetEntityTypeRequest, dict,] +) +def test_get_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2163,10 +2150,6 @@ def test_get_entity_type( assert response.etag == "etag_value" -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. @@ -2353,9 +2336,10 @@ async def test_get_entity_type_flattened_error_async(): ) -def test_list_entity_types( - transport: str = "grpc", request_type=featurestore_service.ListEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListEntityTypesRequest, dict,] +) +def test_list_entity_types(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2384,10 +2368,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. @@ -2584,8 +2564,10 @@ async def test_list_entity_types_flattened_error_async(): ) -def test_list_entity_types_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2626,8 +2608,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 = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2742,9 +2726,10 @@ async def test_list_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_entity_type( - transport: str = "grpc", request_type=featurestore_service.UpdateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateEntityTypeRequest, dict,] +) +def test_update_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2775,10 +2760,6 @@ def test_update_entity_type( assert response.etag == "etag_value" -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. @@ -2997,9 +2978,10 @@ async def test_update_entity_type_flattened_error_async(): ) -def test_delete_entity_type( - transport: str = "grpc", request_type=featurestore_service.DeleteEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteEntityTypeRequest, dict,] +) +def test_delete_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3025,10 +3007,6 @@ def test_delete_entity_type( assert isinstance(response, future.Future) -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. @@ -3234,9 +3212,10 @@ async def test_delete_entity_type_flattened_error_async(): ) -def test_create_feature( - transport: str = "grpc", request_type=featurestore_service.CreateFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateFeatureRequest, dict,] +) +def test_create_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3260,10 +3239,6 @@ def test_create_feature( assert isinstance(response, future.Future) -def test_create_feature_from_dict(): - test_create_feature(request_type=dict) - - def test_create_feature_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. @@ -3471,10 +3446,10 @@ async def test_create_feature_flattened_error_async(): ) -def test_batch_create_features( - transport: str = "grpc", - request_type=featurestore_service.BatchCreateFeaturesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.BatchCreateFeaturesRequest, dict,] +) +def test_batch_create_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3500,10 +3475,6 @@ def test_batch_create_features( assert isinstance(response, future.Future) -def test_batch_create_features_from_dict(): - test_batch_create_features(request_type=dict) - - def test_batch_create_features_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. @@ -3713,9 +3684,10 @@ async def test_batch_create_features_flattened_error_async(): ) -def test_get_feature( - transport: str = "grpc", request_type=featurestore_service.GetFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetFeatureRequest, dict,] +) +def test_get_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3748,10 +3720,6 @@ def test_get_feature( assert response.etag == "etag_value" -def test_get_feature_from_dict(): - test_get_feature(request_type=dict) - - def test_get_feature_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. @@ -3937,9 +3905,10 @@ async def test_get_feature_flattened_error_async(): ) -def test_list_features( - transport: str = "grpc", request_type=featurestore_service.ListFeaturesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListFeaturesRequest, dict,] +) +def test_list_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3966,10 +3935,6 @@ def test_list_features( assert response.next_page_token == "next_page_token_value" -def test_list_features_from_dict(): - test_list_features(request_type=dict) - - def test_list_features_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. @@ -4154,8 +4119,10 @@ async def test_list_features_flattened_error_async(): ) -def test_list_features_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_features_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -4190,8 +4157,10 @@ def test_list_features_pager(): assert all(isinstance(i, feature.Feature) for i in results) -def test_list_features_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_features_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -4288,9 +4257,10 @@ async def test_list_features_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_feature( - transport: str = "grpc", request_type=featurestore_service.UpdateFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateFeatureRequest, dict,] +) +def test_update_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4323,10 +4293,6 @@ def test_update_feature( assert response.etag == "etag_value" -def test_update_feature_from_dict(): - test_update_feature(request_type=dict) - - def test_update_feature_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. @@ -4533,9 +4499,10 @@ async def test_update_feature_flattened_error_async(): ) -def test_delete_feature( - transport: str = "grpc", request_type=featurestore_service.DeleteFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteFeatureRequest, dict,] +) +def test_delete_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4559,10 +4526,6 @@ def test_delete_feature( assert isinstance(response, future.Future) -def test_delete_feature_from_dict(): - test_delete_feature(request_type=dict) - - def test_delete_feature_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. @@ -4744,10 +4707,10 @@ async def test_delete_feature_flattened_error_async(): ) -def test_import_feature_values( - transport: str = "grpc", - request_type=featurestore_service.ImportFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ImportFeatureValuesRequest, dict,] +) +def test_import_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4773,10 +4736,6 @@ def test_import_feature_values( assert isinstance(response, future.Future) -def test_import_feature_values_from_dict(): - test_import_feature_values(request_type=dict) - - def test_import_feature_values_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. @@ -4972,10 +4931,10 @@ async def test_import_feature_values_flattened_error_async(): ) -def test_batch_read_feature_values( - transport: str = "grpc", - request_type=featurestore_service.BatchReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.BatchReadFeatureValuesRequest, dict,] +) +def test_batch_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5001,10 +4960,6 @@ def test_batch_read_feature_values( assert isinstance(response, future.Future) -def test_batch_read_feature_values_from_dict(): - test_batch_read_feature_values(request_type=dict) - - def test_batch_read_feature_values_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. @@ -5206,10 +5161,10 @@ async def test_batch_read_feature_values_flattened_error_async(): ) -def test_export_feature_values( - transport: str = "grpc", - request_type=featurestore_service.ExportFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ExportFeatureValuesRequest, dict,] +) +def test_export_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5235,10 +5190,6 @@ def test_export_feature_values( assert isinstance(response, future.Future) -def test_export_feature_values_from_dict(): - test_export_feature_values(request_type=dict) - - def test_export_feature_values_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. @@ -5434,9 +5385,10 @@ async def test_export_feature_values_flattened_error_async(): ) -def test_search_features( - transport: str = "grpc", request_type=featurestore_service.SearchFeaturesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.SearchFeaturesRequest, dict,] +) +def test_search_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5463,10 +5415,6 @@ def test_search_features( assert response.next_page_token == "next_page_token_value" -def test_search_features_from_dict(): - test_search_features(request_type=dict) - - def test_search_features_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. @@ -5665,8 +5613,10 @@ async def test_search_features_flattened_error_async(): ) -def test_search_features_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_features_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -5701,8 +5651,10 @@ def test_search_features_pager(): assert all(isinstance(i, feature.Feature) for i in results) -def test_search_features_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_features_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -6434,7 +6386,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/aiplatform_v1/test_index_endpoint_service.py b/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py index 2917a37ed9..09c5388f65 100644 --- a/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py @@ -265,20 +265,20 @@ def test_index_endpoint_service_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, @@ -347,7 +347,7 @@ def test_index_endpoint_service_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 @@ -446,7 +446,7 @@ def test_index_endpoint_service_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, @@ -481,7 +481,7 @@ def test_index_endpoint_service_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", @@ -514,10 +514,10 @@ def test_index_endpoint_service_client_client_options_from_dict(): ) -def test_create_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.CreateIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.CreateIndexEndpointRequest, dict,] +) +def test_create_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -543,10 +543,6 @@ def test_create_index_endpoint( assert isinstance(response, future.Future) -def test_create_index_endpoint_from_dict(): - test_create_index_endpoint(request_type=dict) - - def test_create_index_endpoint_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. @@ -756,9 +752,10 @@ async def test_create_index_endpoint_flattened_error_async(): ) -def test_get_index_endpoint( - transport: str = "grpc", request_type=index_endpoint_service.GetIndexEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.GetIndexEndpointRequest, dict,] +) +def test_get_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -797,10 +794,6 @@ def test_get_index_endpoint( assert response.enable_private_service_connect is True -def test_get_index_endpoint_from_dict(): - test_get_index_endpoint(request_type=dict) - - def test_get_index_endpoint_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. @@ -1007,10 +1000,10 @@ async def test_get_index_endpoint_flattened_error_async(): ) -def test_list_index_endpoints( - transport: str = "grpc", - request_type=index_endpoint_service.ListIndexEndpointsRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.ListIndexEndpointsRequest, dict,] +) +def test_list_index_endpoints(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1039,10 +1032,6 @@ def test_list_index_endpoints( assert response.next_page_token == "next_page_token_value" -def test_list_index_endpoints_from_dict(): - test_list_index_endpoints(request_type=dict) - - def test_list_index_endpoints_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,9 @@ async def test_list_index_endpoints_flattened_error_async(): ) -def test_list_index_endpoints_pager(): +def test_list_index_endpoints_pager(transport_name: str = "grpc"): client = IndexEndpointServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1287,9 +1276,9 @@ def test_list_index_endpoints_pager(): assert all(isinstance(i, index_endpoint.IndexEndpoint) for i in results) -def test_list_index_endpoints_pages(): +def test_list_index_endpoints_pages(transport_name: str = "grpc"): client = IndexEndpointServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1417,10 +1406,10 @@ async def test_list_index_endpoints_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.UpdateIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.UpdateIndexEndpointRequest, dict,] +) +def test_update_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1459,10 +1448,6 @@ def test_update_index_endpoint( assert response.enable_private_service_connect is True -def test_update_index_endpoint_from_dict(): - test_update_index_endpoint(request_type=dict) - - def test_update_index_endpoint_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. @@ -1691,10 +1676,10 @@ async def test_update_index_endpoint_flattened_error_async(): ) -def test_delete_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.DeleteIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.DeleteIndexEndpointRequest, dict,] +) +def test_delete_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1720,10 +1705,6 @@ def test_delete_index_endpoint( assert isinstance(response, future.Future) -def test_delete_index_endpoint_from_dict(): - test_delete_index_endpoint(request_type=dict) - - def test_delete_index_endpoint_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. @@ -1917,9 +1898,10 @@ async def test_delete_index_endpoint_flattened_error_async(): ) -def test_deploy_index( - transport: str = "grpc", request_type=index_endpoint_service.DeployIndexRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.DeployIndexRequest, dict,] +) +def test_deploy_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1943,10 +1925,6 @@ def test_deploy_index( assert isinstance(response, future.Future) -def test_deploy_index_from_dict(): - test_deploy_index(request_type=dict) - - def test_deploy_index_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. @@ -2148,9 +2126,10 @@ async def test_deploy_index_flattened_error_async(): ) -def test_undeploy_index( - transport: str = "grpc", request_type=index_endpoint_service.UndeployIndexRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.UndeployIndexRequest, dict,] +) +def test_undeploy_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2174,10 +2153,6 @@ def test_undeploy_index( assert isinstance(response, future.Future) -def test_undeploy_index_from_dict(): - test_undeploy_index(request_type=dict) - - def test_undeploy_index_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. @@ -2379,10 +2354,10 @@ async def test_undeploy_index_flattened_error_async(): ) -def test_mutate_deployed_index( - transport: str = "grpc", - request_type=index_endpoint_service.MutateDeployedIndexRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.MutateDeployedIndexRequest, dict,] +) +def test_mutate_deployed_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2408,10 +2383,6 @@ def test_mutate_deployed_index( assert isinstance(response, future.Future) -def test_mutate_deployed_index_from_dict(): - test_mutate_deployed_index(request_type=dict) - - def test_mutate_deployed_index_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. @@ -3207,7 +3178,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/aiplatform_v1/test_index_service.py b/tests/unit/gapic/aiplatform_v1/test_index_service.py index 56ace1aee2..fc8235bb46 100644 --- a/tests/unit/gapic/aiplatform_v1/test_index_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_index_service.py @@ -248,20 +248,20 @@ def test_index_service_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, @@ -318,7 +318,7 @@ def test_index_service_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 @@ -413,7 +413,7 @@ def test_index_service_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, @@ -444,7 +444,7 @@ def test_index_service_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", @@ -475,9 +475,8 @@ def test_index_service_client_client_options_from_dict(): ) -def test_create_index( - transport: str = "grpc", request_type=index_service.CreateIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.CreateIndexRequest, dict,]) +def test_create_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -501,10 +500,6 @@ def test_create_index( assert isinstance(response, future.Future) -def test_create_index_from_dict(): - test_create_index(request_type=dict) - - def test_create_index_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. @@ -687,7 +682,8 @@ async def test_create_index_flattened_error_async(): ) -def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexRequest): +@pytest.mark.parametrize("request_type", [index_service.GetIndexRequest, dict,]) +def test_get_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -722,10 +718,6 @@ def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexR assert response.etag == "etag_value" -def test_get_index_from_dict(): - test_get_index(request_type=dict) - - def test_get_index_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. @@ -901,9 +893,8 @@ async def test_get_index_flattened_error_async(): ) -def test_list_indexes( - transport: str = "grpc", request_type=index_service.ListIndexesRequest -): +@pytest.mark.parametrize("request_type", [index_service.ListIndexesRequest, dict,]) +def test_list_indexes(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -930,10 +921,6 @@ def test_list_indexes( assert response.next_page_token == "next_page_token_value" -def test_list_indexes_from_dict(): - test_list_indexes(request_type=dict) - - def test_list_indexes_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. @@ -1103,8 +1090,10 @@ async def test_list_indexes_flattened_error_async(): ) -def test_list_indexes_pager(): - client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_indexes_pager(transport_name: str = "grpc"): + client = IndexServiceClient( + 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_indexes), "__call__") as call: @@ -1135,8 +1124,10 @@ def test_list_indexes_pager(): assert all(isinstance(i, index.Index) for i in results) -def test_list_indexes_pages(): - client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_indexes_pages(transport_name: str = "grpc"): + client = IndexServiceClient( + 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_indexes), "__call__") as call: @@ -1217,9 +1208,8 @@ async def test_list_indexes_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_index( - transport: str = "grpc", request_type=index_service.UpdateIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.UpdateIndexRequest, dict,]) +def test_update_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1243,10 +1233,6 @@ def test_update_index( assert isinstance(response, future.Future) -def test_update_index_from_dict(): - test_update_index(request_type=dict) - - def test_update_index_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. @@ -1431,9 +1417,8 @@ async def test_update_index_flattened_error_async(): ) -def test_delete_index( - transport: str = "grpc", request_type=index_service.DeleteIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.DeleteIndexRequest, dict,]) +def test_delete_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1457,10 +1442,6 @@ def test_delete_index( assert isinstance(response, future.Future) -def test_delete_index_from_dict(): - test_delete_index(request_type=dict) - - def test_delete_index_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. @@ -2191,7 +2172,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/aiplatform_v1/test_job_service.py b/tests/unit/gapic/aiplatform_v1/test_job_service.py index 0a0221dc28..ac3465dd74 100644 --- a/tests/unit/gapic/aiplatform_v1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_job_service.py @@ -279,20 +279,20 @@ def test_job_service_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, @@ -349,7 +349,7 @@ def test_job_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -444,7 +444,7 @@ def test_job_service_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, @@ -475,7 +475,7 @@ def test_job_service_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", @@ -506,9 +506,8 @@ def test_job_service_client_client_options_from_dict(): ) -def test_create_custom_job( - transport: str = "grpc", request_type=job_service.CreateCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.CreateCustomJobRequest, dict,]) +def test_create_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -541,10 +540,6 @@ def test_create_custom_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_custom_job_from_dict(): - test_create_custom_job(request_type=dict) - - def test_create_custom_job_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. @@ -748,9 +743,8 @@ async def test_create_custom_job_flattened_error_async(): ) -def test_get_custom_job( - transport: str = "grpc", request_type=job_service.GetCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.GetCustomJobRequest, dict,]) +def test_get_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -781,10 +775,6 @@ def test_get_custom_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_custom_job_from_dict(): - test_get_custom_job(request_type=dict) - - def test_get_custom_job_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. @@ -960,9 +950,8 @@ async def test_get_custom_job_flattened_error_async(): ) -def test_list_custom_jobs( - transport: str = "grpc", request_type=job_service.ListCustomJobsRequest -): +@pytest.mark.parametrize("request_type", [job_service.ListCustomJobsRequest, dict,]) +def test_list_custom_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -989,10 +978,6 @@ def test_list_custom_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_custom_jobs_from_dict(): - test_list_custom_jobs(request_type=dict) - - def test_list_custom_jobs_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. @@ -1162,8 +1147,10 @@ async def test_list_custom_jobs_flattened_error_async(): ) -def test_list_custom_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_custom_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_custom_jobs), "__call__") as call: @@ -1200,8 +1187,10 @@ def test_list_custom_jobs_pager(): assert all(isinstance(i, custom_job.CustomJob) for i in results) -def test_list_custom_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_custom_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_custom_jobs), "__call__") as call: @@ -1300,9 +1289,8 @@ async def test_list_custom_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_custom_job( - transport: str = "grpc", request_type=job_service.DeleteCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.DeleteCustomJobRequest, dict,]) +def test_delete_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1328,10 +1316,6 @@ def test_delete_custom_job( assert isinstance(response, future.Future) -def test_delete_custom_job_from_dict(): - test_delete_custom_job(request_type=dict) - - def test_delete_custom_job_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. @@ -1512,9 +1496,8 @@ async def test_delete_custom_job_flattened_error_async(): ) -def test_cancel_custom_job( - transport: str = "grpc", request_type=job_service.CancelCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.CancelCustomJobRequest, dict,]) +def test_cancel_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1540,10 +1523,6 @@ def test_cancel_custom_job( assert response is None -def test_cancel_custom_job_from_dict(): - test_cancel_custom_job(request_type=dict) - - def test_cancel_custom_job_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. @@ -1718,9 +1697,10 @@ async def test_cancel_custom_job_flattened_error_async(): ) -def test_create_data_labeling_job( - transport: str = "grpc", request_type=job_service.CreateDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateDataLabelingJobRequest, dict,] +) +def test_create_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1765,10 +1745,6 @@ def test_create_data_labeling_job( assert response.specialist_pools == ["specialist_pools_value"] -def test_create_data_labeling_job_from_dict(): - test_create_data_labeling_job(request_type=dict) - - def test_create_data_labeling_job_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. @@ -1985,9 +1961,8 @@ async def test_create_data_labeling_job_flattened_error_async(): ) -def test_get_data_labeling_job( - transport: str = "grpc", request_type=job_service.GetDataLabelingJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.GetDataLabelingJobRequest, dict,]) +def test_get_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2032,10 +2007,6 @@ def test_get_data_labeling_job( assert response.specialist_pools == ["specialist_pools_value"] -def test_get_data_labeling_job_from_dict(): - test_get_data_labeling_job(request_type=dict) - - def test_get_data_labeling_job_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. @@ -2235,9 +2206,10 @@ async def test_get_data_labeling_job_flattened_error_async(): ) -def test_list_data_labeling_jobs( - transport: str = "grpc", request_type=job_service.ListDataLabelingJobsRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.ListDataLabelingJobsRequest, dict,] +) +def test_list_data_labeling_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2266,10 +2238,6 @@ def test_list_data_labeling_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_data_labeling_jobs_from_dict(): - test_list_data_labeling_jobs(request_type=dict) - - def test_list_data_labeling_jobs_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. @@ -2454,8 +2422,10 @@ async def test_list_data_labeling_jobs_flattened_error_async(): ) -def test_list_data_labeling_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_labeling_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2500,8 +2470,10 @@ def test_list_data_labeling_jobs_pager(): assert all(isinstance(i, data_labeling_job.DataLabelingJob) for i in results) -def test_list_data_labeling_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_labeling_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2624,9 +2596,10 @@ async def test_list_data_labeling_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_data_labeling_job( - transport: str = "grpc", request_type=job_service.DeleteDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteDataLabelingJobRequest, dict,] +) +def test_delete_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2652,10 +2625,6 @@ def test_delete_data_labeling_job( assert isinstance(response, future.Future) -def test_delete_data_labeling_job_from_dict(): - test_delete_data_labeling_job(request_type=dict) - - def test_delete_data_labeling_job_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. @@ -2837,9 +2806,10 @@ async def test_delete_data_labeling_job_flattened_error_async(): ) -def test_cancel_data_labeling_job( - transport: str = "grpc", request_type=job_service.CancelDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelDataLabelingJobRequest, dict,] +) +def test_cancel_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2865,10 +2835,6 @@ def test_cancel_data_labeling_job( assert response is None -def test_cancel_data_labeling_job_from_dict(): - test_cancel_data_labeling_job(request_type=dict) - - def test_cancel_data_labeling_job_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. @@ -3044,10 +3010,10 @@ async def test_cancel_data_labeling_job_flattened_error_async(): ) -def test_create_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.CreateHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateHyperparameterTuningJobRequest, dict,] +) +def test_create_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3086,10 +3052,6 @@ def test_create_hyperparameter_tuning_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_hyperparameter_tuning_job_from_dict(): - test_create_hyperparameter_tuning_job(request_type=dict) - - def test_create_hyperparameter_tuning_job_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. @@ -3312,9 +3274,10 @@ async def test_create_hyperparameter_tuning_job_flattened_error_async(): ) -def test_get_hyperparameter_tuning_job( - transport: str = "grpc", request_type=job_service.GetHyperparameterTuningJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.GetHyperparameterTuningJobRequest, dict,] +) +def test_get_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3353,10 +3316,6 @@ def test_get_hyperparameter_tuning_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_hyperparameter_tuning_job_from_dict(): - test_get_hyperparameter_tuning_job(request_type=dict) - - def test_get_hyperparameter_tuning_job_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. @@ -3551,10 +3510,10 @@ async def test_get_hyperparameter_tuning_job_flattened_error_async(): ) -def test_list_hyperparameter_tuning_jobs( - transport: str = "grpc", - request_type=job_service.ListHyperparameterTuningJobsRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ListHyperparameterTuningJobsRequest, dict,] +) +def test_list_hyperparameter_tuning_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3583,10 +3542,6 @@ def test_list_hyperparameter_tuning_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_hyperparameter_tuning_jobs_from_dict(): - test_list_hyperparameter_tuning_jobs(request_type=dict) - - def test_list_hyperparameter_tuning_jobs_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. @@ -3771,8 +3726,10 @@ async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): ) -def test_list_hyperparameter_tuning_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_hyperparameter_tuning_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3822,8 +3779,10 @@ def test_list_hyperparameter_tuning_jobs_pager(): ) -def test_list_hyperparameter_tuning_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_hyperparameter_tuning_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3957,10 +3916,10 @@ async def test_list_hyperparameter_tuning_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.DeleteHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteHyperparameterTuningJobRequest, dict,] +) +def test_delete_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3986,10 +3945,6 @@ def test_delete_hyperparameter_tuning_job( assert isinstance(response, future.Future) -def test_delete_hyperparameter_tuning_job_from_dict(): - test_delete_hyperparameter_tuning_job(request_type=dict) - - def test_delete_hyperparameter_tuning_job_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. @@ -4171,10 +4126,10 @@ async def test_delete_hyperparameter_tuning_job_flattened_error_async(): ) -def test_cancel_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.CancelHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelHyperparameterTuningJobRequest, dict,] +) +def test_cancel_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4200,10 +4155,6 @@ def test_cancel_hyperparameter_tuning_job( assert response is None -def test_cancel_hyperparameter_tuning_job_from_dict(): - test_cancel_hyperparameter_tuning_job(request_type=dict) - - def test_cancel_hyperparameter_tuning_job_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. @@ -4379,9 +4330,10 @@ async def test_cancel_hyperparameter_tuning_job_flattened_error_async(): ) -def test_create_batch_prediction_job( - transport: str = "grpc", request_type=job_service.CreateBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateBatchPredictionJobRequest, dict,] +) +def test_create_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4418,10 +4370,6 @@ def test_create_batch_prediction_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_batch_prediction_job_from_dict(): - test_create_batch_prediction_job(request_type=dict) - - def test_create_batch_prediction_job_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. @@ -4638,9 +4586,10 @@ async def test_create_batch_prediction_job_flattened_error_async(): ) -def test_get_batch_prediction_job( - transport: str = "grpc", request_type=job_service.GetBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.GetBatchPredictionJobRequest, dict,] +) +def test_get_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4677,10 +4626,6 @@ def test_get_batch_prediction_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_batch_prediction_job_from_dict(): - test_get_batch_prediction_job(request_type=dict) - - def test_get_batch_prediction_job_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. @@ -4873,9 +4818,10 @@ async def test_get_batch_prediction_job_flattened_error_async(): ) -def test_list_batch_prediction_jobs( - transport: str = "grpc", request_type=job_service.ListBatchPredictionJobsRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.ListBatchPredictionJobsRequest, dict,] +) +def test_list_batch_prediction_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4904,10 +4850,6 @@ def test_list_batch_prediction_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_batch_prediction_jobs_from_dict(): - test_list_batch_prediction_jobs(request_type=dict) - - def test_list_batch_prediction_jobs_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. @@ -5092,8 +5034,10 @@ async def test_list_batch_prediction_jobs_flattened_error_async(): ) -def test_list_batch_prediction_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_batch_prediction_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5140,8 +5084,10 @@ def test_list_batch_prediction_jobs_pager(): ) -def test_list_batch_prediction_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_batch_prediction_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5266,9 +5212,10 @@ async def test_list_batch_prediction_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_batch_prediction_job( - transport: str = "grpc", request_type=job_service.DeleteBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteBatchPredictionJobRequest, dict,] +) +def test_delete_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5294,10 +5241,6 @@ def test_delete_batch_prediction_job( assert isinstance(response, future.Future) -def test_delete_batch_prediction_job_from_dict(): - test_delete_batch_prediction_job(request_type=dict) - - def test_delete_batch_prediction_job_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. @@ -5479,9 +5422,10 @@ async def test_delete_batch_prediction_job_flattened_error_async(): ) -def test_cancel_batch_prediction_job( - transport: str = "grpc", request_type=job_service.CancelBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelBatchPredictionJobRequest, dict,] +) +def test_cancel_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5507,10 +5451,6 @@ def test_cancel_batch_prediction_job( assert response is None -def test_cancel_batch_prediction_job_from_dict(): - test_cancel_batch_prediction_job(request_type=dict) - - def test_cancel_batch_prediction_job_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. @@ -5686,10 +5626,10 @@ async def test_cancel_batch_prediction_job_flattened_error_async(): ) -def test_create_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.CreateModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateModelDeploymentMonitoringJobRequest, dict,] +) +def test_create_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5737,10 +5677,6 @@ def test_create_model_deployment_monitoring_job( assert response.enable_monitoring_pipeline_logs is True -def test_create_model_deployment_monitoring_job_from_dict(): - test_create_model_deployment_monitoring_job(request_type=dict) - - def test_create_model_deployment_monitoring_job_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. @@ -5978,9 +5914,12 @@ async def test_create_model_deployment_monitoring_job_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict,], +) def test_search_model_deployment_monitoring_stats_anomalies( - transport: str = "grpc", - request_type=job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, + request_type, transport: str = "grpc" ): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6016,10 +5955,6 @@ def test_search_model_deployment_monitoring_stats_anomalies( assert response.next_page_token == "next_page_token_value" -def test_search_model_deployment_monitoring_stats_anomalies_from_dict(): - test_search_model_deployment_monitoring_stats_anomalies(request_type=dict) - - def test_search_model_deployment_monitoring_stats_anomalies_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. @@ -6250,8 +6185,12 @@ async def test_search_model_deployment_monitoring_stats_anomalies_flattened_erro ) -def test_search_model_deployment_monitoring_stats_anomalies_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_model_deployment_monitoring_stats_anomalies_pager( + transport_name: str = "grpc", +): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6306,8 +6245,12 @@ def test_search_model_deployment_monitoring_stats_anomalies_pager(): ) -def test_search_model_deployment_monitoring_stats_anomalies_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_model_deployment_monitoring_stats_anomalies_pages( + transport_name: str = "grpc", +): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6448,10 +6391,10 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.GetModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.GetModelDeploymentMonitoringJobRequest, dict,] +) +def test_get_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6499,10 +6442,6 @@ def test_get_model_deployment_monitoring_job( assert response.enable_monitoring_pipeline_logs is True -def test_get_model_deployment_monitoring_job_from_dict(): - test_get_model_deployment_monitoring_job(request_type=dict) - - def test_get_model_deployment_monitoring_job_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. @@ -6712,10 +6651,10 @@ async def test_get_model_deployment_monitoring_job_flattened_error_async(): ) -def test_list_model_deployment_monitoring_jobs( - transport: str = "grpc", - request_type=job_service.ListModelDeploymentMonitoringJobsRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ListModelDeploymentMonitoringJobsRequest, dict,] +) +def test_list_model_deployment_monitoring_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6744,10 +6683,6 @@ def test_list_model_deployment_monitoring_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_model_deployment_monitoring_jobs_from_dict(): - test_list_model_deployment_monitoring_jobs(request_type=dict) - - def test_list_model_deployment_monitoring_jobs_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. @@ -6936,8 +6871,10 @@ async def test_list_model_deployment_monitoring_jobs_flattened_error_async(): ) -def test_list_model_deployment_monitoring_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_deployment_monitoring_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6987,8 +6924,10 @@ def test_list_model_deployment_monitoring_jobs_pager(): ) -def test_list_model_deployment_monitoring_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_deployment_monitoring_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7122,10 +7061,10 @@ async def test_list_model_deployment_monitoring_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.UpdateModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.UpdateModelDeploymentMonitoringJobRequest, dict,] +) +def test_update_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7151,10 +7090,6 @@ def test_update_model_deployment_monitoring_job( assert isinstance(response, future.Future) -def test_update_model_deployment_monitoring_job_from_dict(): - test_update_model_deployment_monitoring_job(request_type=dict) - - def test_update_model_deployment_monitoring_job_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. @@ -7374,10 +7309,10 @@ async def test_update_model_deployment_monitoring_job_flattened_error_async(): ) -def test_delete_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.DeleteModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteModelDeploymentMonitoringJobRequest, dict,] +) +def test_delete_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7403,10 +7338,6 @@ def test_delete_model_deployment_monitoring_job( assert isinstance(response, future.Future) -def test_delete_model_deployment_monitoring_job_from_dict(): - test_delete_model_deployment_monitoring_job(request_type=dict) - - def test_delete_model_deployment_monitoring_job_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. @@ -7590,10 +7521,10 @@ async def test_delete_model_deployment_monitoring_job_flattened_error_async(): ) -def test_pause_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.PauseModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.PauseModelDeploymentMonitoringJobRequest, dict,] +) +def test_pause_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7619,10 +7550,6 @@ def test_pause_model_deployment_monitoring_job( assert response is None -def test_pause_model_deployment_monitoring_job_from_dict(): - test_pause_model_deployment_monitoring_job(request_type=dict) - - def test_pause_model_deployment_monitoring_job_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. @@ -7800,10 +7727,10 @@ async def test_pause_model_deployment_monitoring_job_flattened_error_async(): ) -def test_resume_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.ResumeModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ResumeModelDeploymentMonitoringJobRequest, dict,] +) +def test_resume_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7829,10 +7756,6 @@ def test_resume_model_deployment_monitoring_job( assert response is None -def test_resume_model_deployment_monitoring_job_from_dict(): - test_resume_model_deployment_monitoring_job(request_type=dict) - - def test_resume_model_deployment_monitoring_job_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. @@ -8817,7 +8740,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/aiplatform_v1/test_metadata_service.py b/tests/unit/gapic/aiplatform_v1/test_metadata_service.py index 472a3f0949..bc36f9755d 100644 --- a/tests/unit/gapic/aiplatform_v1/test_metadata_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_metadata_service.py @@ -269,20 +269,20 @@ def test_metadata_service_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, @@ -351,7 +351,7 @@ def test_metadata_service_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 @@ -446,7 +446,7 @@ def test_metadata_service_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_metadata_service_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,9 +510,10 @@ def test_metadata_service_client_client_options_from_dict(): ) -def test_create_metadata_store( - transport: str = "grpc", request_type=metadata_service.CreateMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateMetadataStoreRequest, dict,] +) +def test_create_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -538,10 +539,6 @@ def test_create_metadata_store( assert isinstance(response, future.Future) -def test_create_metadata_store_from_dict(): - test_create_metadata_store(request_type=dict) - - def test_create_metadata_store_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. @@ -755,9 +752,10 @@ async def test_create_metadata_store_flattened_error_async(): ) -def test_get_metadata_store( - transport: str = "grpc", request_type=metadata_service.GetMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.GetMetadataStoreRequest, dict,] +) +def test_get_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -787,10 +785,6 @@ def test_get_metadata_store( assert response.description == "description_value" -def test_get_metadata_store_from_dict(): - test_get_metadata_store(request_type=dict) - - def test_get_metadata_store_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. @@ -982,9 +976,10 @@ async def test_get_metadata_store_flattened_error_async(): ) -def test_list_metadata_stores( - transport: str = "grpc", request_type=metadata_service.ListMetadataStoresRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListMetadataStoresRequest, dict,] +) +def test_list_metadata_stores(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1013,10 +1008,6 @@ def test_list_metadata_stores( assert response.next_page_token == "next_page_token_value" -def test_list_metadata_stores_from_dict(): - test_list_metadata_stores(request_type=dict) - - def test_list_metadata_stores_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. @@ -1207,8 +1198,10 @@ async def test_list_metadata_stores_flattened_error_async(): ) -def test_list_metadata_stores_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_stores_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1253,8 +1246,10 @@ def test_list_metadata_stores_pager(): assert all(isinstance(i, metadata_store.MetadataStore) for i in results) -def test_list_metadata_stores_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_stores_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1381,9 +1376,10 @@ async def test_list_metadata_stores_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_metadata_store( - transport: str = "grpc", request_type=metadata_service.DeleteMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteMetadataStoreRequest, dict,] +) +def test_delete_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1409,10 +1405,6 @@ def test_delete_metadata_store( assert isinstance(response, future.Future) -def test_delete_metadata_store_from_dict(): - test_delete_metadata_store(request_type=dict) - - def test_delete_metadata_store_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. @@ -1600,9 +1592,10 @@ async def test_delete_metadata_store_flattened_error_async(): ) -def test_create_artifact( - transport: str = "grpc", request_type=metadata_service.CreateArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateArtifactRequest, dict,] +) +def test_create_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1643,10 +1636,6 @@ def test_create_artifact( assert response.description == "description_value" -def test_create_artifact_from_dict(): - test_create_artifact(request_type=dict) - - def test_create_artifact_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. @@ -1864,9 +1853,8 @@ async def test_create_artifact_flattened_error_async(): ) -def test_get_artifact( - transport: str = "grpc", request_type=metadata_service.GetArtifactRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetArtifactRequest, dict,]) +def test_get_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1907,10 +1895,6 @@ def test_get_artifact( assert response.description == "description_value" -def test_get_artifact_from_dict(): - test_get_artifact(request_type=dict) - - def test_get_artifact_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. @@ -2098,9 +2082,8 @@ async def test_get_artifact_flattened_error_async(): ) -def test_list_artifacts( - transport: str = "grpc", request_type=metadata_service.ListArtifactsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.ListArtifactsRequest, dict,]) +def test_list_artifacts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2127,10 +2110,6 @@ def test_list_artifacts( assert response.next_page_token == "next_page_token_value" -def test_list_artifacts_from_dict(): - test_list_artifacts(request_type=dict) - - def test_list_artifacts_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. @@ -2308,8 +2287,10 @@ async def test_list_artifacts_flattened_error_async(): ) -def test_list_artifacts_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_artifacts_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_artifacts), "__call__") as call: @@ -2348,8 +2329,10 @@ def test_list_artifacts_pager(): assert all(isinstance(i, artifact.Artifact) for i in results) -def test_list_artifacts_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_artifacts_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_artifacts), "__call__") as call: @@ -2458,9 +2441,10 @@ async def test_list_artifacts_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_artifact( - transport: str = "grpc", request_type=metadata_service.UpdateArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.UpdateArtifactRequest, dict,] +) +def test_update_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2501,10 +2485,6 @@ def test_update_artifact( assert response.description == "description_value" -def test_update_artifact_from_dict(): - test_update_artifact(request_type=dict) - - def test_update_artifact_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. @@ -2716,9 +2696,10 @@ async def test_update_artifact_flattened_error_async(): ) -def test_delete_artifact( - transport: str = "grpc", request_type=metadata_service.DeleteArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteArtifactRequest, dict,] +) +def test_delete_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2742,10 +2723,6 @@ def test_delete_artifact( assert isinstance(response, future.Future) -def test_delete_artifact_from_dict(): - test_delete_artifact(request_type=dict) - - def test_delete_artifact_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. @@ -2920,9 +2897,10 @@ async def test_delete_artifact_flattened_error_async(): ) -def test_purge_artifacts( - transport: str = "grpc", request_type=metadata_service.PurgeArtifactsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.PurgeArtifactsRequest, dict,] +) +def test_purge_artifacts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2946,10 +2924,6 @@ def test_purge_artifacts( assert isinstance(response, future.Future) -def test_purge_artifacts_from_dict(): - test_purge_artifacts(request_type=dict) - - def test_purge_artifacts_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. @@ -3124,9 +3098,8 @@ async def test_purge_artifacts_flattened_error_async(): ) -def test_create_context( - transport: str = "grpc", request_type=metadata_service.CreateContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.CreateContextRequest, dict,]) +def test_create_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3165,10 +3138,6 @@ def test_create_context( assert response.description == "description_value" -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. @@ -3380,9 +3349,8 @@ async def test_create_context_flattened_error_async(): ) -def test_get_context( - transport: str = "grpc", request_type=metadata_service.GetContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetContextRequest, dict,]) +def test_get_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3421,10 +3389,6 @@ def test_get_context( assert response.description == "description_value" -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. @@ -3610,9 +3574,8 @@ async def test_get_context_flattened_error_async(): ) -def test_list_contexts( - transport: str = "grpc", request_type=metadata_service.ListContextsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.ListContextsRequest, dict,]) +def test_list_contexts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3639,10 +3602,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. @@ -3820,8 +3779,10 @@ async def test_list_contexts_flattened_error_async(): ) -def test_list_contexts_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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: @@ -3854,8 +3815,10 @@ def test_list_contexts_pager(): assert all(isinstance(i, context.Context) for i in results) -def test_list_contexts_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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: @@ -3946,9 +3909,8 @@ async def test_list_contexts_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_context( - transport: str = "grpc", request_type=metadata_service.UpdateContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.UpdateContextRequest, dict,]) +def test_update_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3987,10 +3949,6 @@ def test_update_context( assert response.description == "description_value" -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. @@ -4196,9 +4154,8 @@ async def test_update_context_flattened_error_async(): ) -def test_delete_context( - transport: str = "grpc", request_type=metadata_service.DeleteContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.DeleteContextRequest, dict,]) +def test_delete_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4222,10 +4179,6 @@ def test_delete_context( assert isinstance(response, future.Future) -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. @@ -4400,9 +4353,8 @@ async def test_delete_context_flattened_error_async(): ) -def test_purge_contexts( - transport: str = "grpc", request_type=metadata_service.PurgeContextsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.PurgeContextsRequest, dict,]) +def test_purge_contexts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4426,10 +4378,6 @@ def test_purge_contexts( assert isinstance(response, future.Future) -def test_purge_contexts_from_dict(): - test_purge_contexts(request_type=dict) - - def test_purge_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. @@ -4604,10 +4552,10 @@ async def test_purge_contexts_flattened_error_async(): ) -def test_add_context_artifacts_and_executions( - transport: str = "grpc", - request_type=metadata_service.AddContextArtifactsAndExecutionsRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddContextArtifactsAndExecutionsRequest, dict,] +) +def test_add_context_artifacts_and_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4635,10 +4583,6 @@ def test_add_context_artifacts_and_executions( ) -def test_add_context_artifacts_and_executions_from_dict(): - test_add_context_artifacts_and_executions(request_type=dict) - - def test_add_context_artifacts_and_executions_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. @@ -4854,9 +4798,10 @@ async def test_add_context_artifacts_and_executions_flattened_error_async(): ) -def test_add_context_children( - transport: str = "grpc", request_type=metadata_service.AddContextChildrenRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddContextChildrenRequest, dict,] +) +def test_add_context_children(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4882,10 +4827,6 @@ def test_add_context_children( assert isinstance(response, metadata_service.AddContextChildrenResponse) -def test_add_context_children_from_dict(): - test_add_context_children(request_type=dict) - - def test_add_context_children_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. @@ -5087,10 +5028,10 @@ async def test_add_context_children_flattened_error_async(): ) -def test_query_context_lineage_subgraph( - transport: str = "grpc", - request_type=metadata_service.QueryContextLineageSubgraphRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryContextLineageSubgraphRequest, dict,] +) +def test_query_context_lineage_subgraph(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5116,10 +5057,6 @@ def test_query_context_lineage_subgraph( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_context_lineage_subgraph_from_dict(): - test_query_context_lineage_subgraph(request_type=dict) - - def test_query_context_lineage_subgraph_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. @@ -5309,9 +5246,10 @@ async def test_query_context_lineage_subgraph_flattened_error_async(): ) -def test_create_execution( - transport: str = "grpc", request_type=metadata_service.CreateExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateExecutionRequest, dict,] +) +def test_create_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5350,10 +5288,6 @@ def test_create_execution( assert response.description == "description_value" -def test_create_execution_from_dict(): - test_create_execution(request_type=dict) - - def test_create_execution_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. @@ -5570,9 +5504,8 @@ async def test_create_execution_flattened_error_async(): ) -def test_get_execution( - transport: str = "grpc", request_type=metadata_service.GetExecutionRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetExecutionRequest, dict,]) +def test_get_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5611,10 +5544,6 @@ def test_get_execution( assert response.description == "description_value" -def test_get_execution_from_dict(): - test_get_execution(request_type=dict) - - def test_get_execution_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. @@ -5800,9 +5729,10 @@ async def test_get_execution_flattened_error_async(): ) -def test_list_executions( - transport: str = "grpc", request_type=metadata_service.ListExecutionsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListExecutionsRequest, dict,] +) +def test_list_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5829,10 +5759,6 @@ def test_list_executions( assert response.next_page_token == "next_page_token_value" -def test_list_executions_from_dict(): - test_list_executions(request_type=dict) - - def test_list_executions_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. @@ -6010,8 +5936,10 @@ async def test_list_executions_flattened_error_async(): ) -def test_list_executions_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_executions_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_executions), "__call__") as call: @@ -6050,8 +5978,10 @@ def test_list_executions_pager(): assert all(isinstance(i, execution.Execution) for i in results) -def test_list_executions_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_executions_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_executions), "__call__") as call: @@ -6160,9 +6090,10 @@ async def test_list_executions_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_execution( - transport: str = "grpc", request_type=metadata_service.UpdateExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.UpdateExecutionRequest, dict,] +) +def test_update_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6201,10 +6132,6 @@ def test_update_execution( assert response.description == "description_value" -def test_update_execution_from_dict(): - test_update_execution(request_type=dict) - - def test_update_execution_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. @@ -6415,9 +6342,10 @@ async def test_update_execution_flattened_error_async(): ) -def test_delete_execution( - transport: str = "grpc", request_type=metadata_service.DeleteExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteExecutionRequest, dict,] +) +def test_delete_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6441,10 +6369,6 @@ def test_delete_execution( assert isinstance(response, future.Future) -def test_delete_execution_from_dict(): - test_delete_execution(request_type=dict) - - def test_delete_execution_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. @@ -6620,9 +6544,10 @@ async def test_delete_execution_flattened_error_async(): ) -def test_purge_executions( - transport: str = "grpc", request_type=metadata_service.PurgeExecutionsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.PurgeExecutionsRequest, dict,] +) +def test_purge_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6646,10 +6571,6 @@ def test_purge_executions( assert isinstance(response, future.Future) -def test_purge_executions_from_dict(): - test_purge_executions(request_type=dict) - - def test_purge_executions_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. @@ -6825,9 +6746,10 @@ async def test_purge_executions_flattened_error_async(): ) -def test_add_execution_events( - transport: str = "grpc", request_type=metadata_service.AddExecutionEventsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddExecutionEventsRequest, dict,] +) +def test_add_execution_events(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6853,10 +6775,6 @@ def test_add_execution_events( assert isinstance(response, metadata_service.AddExecutionEventsResponse) -def test_add_execution_events_from_dict(): - test_add_execution_events(request_type=dict) - - def test_add_execution_events_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. @@ -7060,10 +6978,10 @@ async def test_add_execution_events_flattened_error_async(): ) -def test_query_execution_inputs_and_outputs( - transport: str = "grpc", - request_type=metadata_service.QueryExecutionInputsAndOutputsRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryExecutionInputsAndOutputsRequest, dict,] +) +def test_query_execution_inputs_and_outputs(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7089,10 +7007,6 @@ def test_query_execution_inputs_and_outputs( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_execution_inputs_and_outputs_from_dict(): - test_query_execution_inputs_and_outputs(request_type=dict) - - def test_query_execution_inputs_and_outputs_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. @@ -7284,9 +7198,10 @@ async def test_query_execution_inputs_and_outputs_flattened_error_async(): ) -def test_create_metadata_schema( - transport: str = "grpc", request_type=metadata_service.CreateMetadataSchemaRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateMetadataSchemaRequest, dict,] +) +def test_create_metadata_schema(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7326,10 +7241,6 @@ def test_create_metadata_schema( assert response.description == "description_value" -def test_create_metadata_schema_from_dict(): - test_create_metadata_schema(request_type=dict) - - def test_create_metadata_schema_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. @@ -7557,9 +7468,10 @@ async def test_create_metadata_schema_flattened_error_async(): ) -def test_get_metadata_schema( - transport: str = "grpc", request_type=metadata_service.GetMetadataSchemaRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.GetMetadataSchemaRequest, dict,] +) +def test_get_metadata_schema(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7599,10 +7511,6 @@ def test_get_metadata_schema( assert response.description == "description_value" -def test_get_metadata_schema_from_dict(): - test_get_metadata_schema(request_type=dict) - - def test_get_metadata_schema_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. @@ -7804,9 +7712,10 @@ async def test_get_metadata_schema_flattened_error_async(): ) -def test_list_metadata_schemas( - transport: str = "grpc", request_type=metadata_service.ListMetadataSchemasRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListMetadataSchemasRequest, dict,] +) +def test_list_metadata_schemas(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7835,10 +7744,6 @@ def test_list_metadata_schemas( assert response.next_page_token == "next_page_token_value" -def test_list_metadata_schemas_from_dict(): - test_list_metadata_schemas(request_type=dict) - - def test_list_metadata_schemas_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. @@ -8029,8 +7934,10 @@ async def test_list_metadata_schemas_flattened_error_async(): ) -def test_list_metadata_schemas_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_schemas_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8075,8 +7982,10 @@ def test_list_metadata_schemas_pager(): assert all(isinstance(i, metadata_schema.MetadataSchema) for i in results) -def test_list_metadata_schemas_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_schemas_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8203,10 +8112,10 @@ async def test_list_metadata_schemas_async_pages(): assert page_.raw_page.next_page_token == token -def test_query_artifact_lineage_subgraph( - transport: str = "grpc", - request_type=metadata_service.QueryArtifactLineageSubgraphRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryArtifactLineageSubgraphRequest, dict,] +) +def test_query_artifact_lineage_subgraph(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -8232,10 +8141,6 @@ def test_query_artifact_lineage_subgraph( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_artifact_lineage_subgraph_from_dict(): - test_query_artifact_lineage_subgraph(request_type=dict) - - def test_query_artifact_lineage_subgraph_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. @@ -9128,7 +9033,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/aiplatform_v1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1/test_migration_service.py index 15277d3072..d292599e68 100644 --- a/tests/unit/gapic/aiplatform_v1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_migration_service.py @@ -254,20 +254,20 @@ def test_migration_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -336,7 +336,7 @@ def test_migration_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -431,7 +431,7 @@ def test_migration_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -462,7 +462,7 @@ def test_migration_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -495,10 +495,10 @@ def test_migration_service_client_client_options_from_dict(): ) -def test_search_migratable_resources( - transport: str = "grpc", - request_type=migration_service.SearchMigratableResourcesRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.SearchMigratableResourcesRequest, dict,] +) +def test_search_migratable_resources(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -527,10 +527,6 @@ def test_search_migratable_resources( assert response.next_page_token == "next_page_token_value" -def test_search_migratable_resources_from_dict(): - test_search_migratable_resources(request_type=dict) - - def test_search_migratable_resources_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. @@ -721,8 +717,10 @@ async def test_search_migratable_resources_flattened_error_async(): ) -def test_search_migratable_resources_pager(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_migratable_resources_pager(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -769,8 +767,10 @@ def test_search_migratable_resources_pager(): ) -def test_search_migratable_resources_pages(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_migratable_resources_pages(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -899,9 +899,10 @@ async def test_search_migratable_resources_async_pages(): assert page_.raw_page.next_page_token == token -def test_batch_migrate_resources( - transport: str = "grpc", request_type=migration_service.BatchMigrateResourcesRequest -): +@pytest.mark.parametrize( + "request_type", [migration_service.BatchMigrateResourcesRequest, dict,] +) +def test_batch_migrate_resources(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -927,10 +928,6 @@ def test_batch_migrate_resources( assert isinstance(response, future.Future) -def test_batch_migrate_resources_from_dict(): - test_batch_migrate_resources(request_type=dict) - - def test_batch_migrate_resources_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. @@ -1860,7 +1857,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/aiplatform_v1/test_model_service.py b/tests/unit/gapic/aiplatform_v1/test_model_service.py index d3252ec4eb..680af66a2d 100644 --- a/tests/unit/gapic/aiplatform_v1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_model_service.py @@ -255,20 +255,20 @@ def test_model_service_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_model_service_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_model_service_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_model_service_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", @@ -482,9 +482,8 @@ def test_model_service_client_client_options_from_dict(): ) -def test_upload_model( - transport: str = "grpc", request_type=model_service.UploadModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.UploadModelRequest, dict,]) +def test_upload_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -508,10 +507,6 @@ def test_upload_model( assert isinstance(response, future.Future) -def test_upload_model_from_dict(): - test_upload_model(request_type=dict) - - def test_upload_model_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. @@ -694,7 +689,8 @@ async def test_upload_model_flattened_error_async(): ) -def test_get_model(transport: str = "grpc", request_type=model_service.GetModelRequest): +@pytest.mark.parametrize("request_type", [model_service.GetModelRequest, dict,]) +def test_get_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -747,10 +743,6 @@ def test_get_model(transport: str = "grpc", request_type=model_service.GetModelR assert response.etag == "etag_value" -def test_get_model_from_dict(): - test_get_model(request_type=dict) - - def test_get_model_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. @@ -948,9 +940,8 @@ async def test_get_model_flattened_error_async(): ) -def test_list_models( - transport: str = "grpc", request_type=model_service.ListModelsRequest -): +@pytest.mark.parametrize("request_type", [model_service.ListModelsRequest, dict,]) +def test_list_models(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -977,10 +968,6 @@ def test_list_models( assert response.next_page_token == "next_page_token_value" -def test_list_models_from_dict(): - test_list_models(request_type=dict) - - def test_list_models_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_models_flattened_error_async(): ) -def test_list_models_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_models_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + 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_models), "__call__") as call: @@ -1182,8 +1171,10 @@ def test_list_models_pager(): assert all(isinstance(i, model.Model) for i in results) -def test_list_models_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_models_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + 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_models), "__call__") as call: @@ -1264,9 +1255,8 @@ async def test_list_models_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_model( - transport: str = "grpc", request_type=model_service.UpdateModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.UpdateModelRequest, dict,]) +def test_update_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1319,10 +1309,6 @@ def test_update_model( assert response.etag == "etag_value" -def test_update_model_from_dict(): - test_update_model(request_type=dict) - - def test_update_model_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. @@ -1536,9 +1522,8 @@ async def test_update_model_flattened_error_async(): ) -def test_delete_model( - transport: str = "grpc", request_type=model_service.DeleteModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.DeleteModelRequest, dict,]) +def test_delete_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1562,10 +1547,6 @@ def test_delete_model( assert isinstance(response, future.Future) -def test_delete_model_from_dict(): - test_delete_model(request_type=dict) - - def test_delete_model_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. @@ -1734,9 +1715,8 @@ async def test_delete_model_flattened_error_async(): ) -def test_export_model( - transport: str = "grpc", request_type=model_service.ExportModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.ExportModelRequest, dict,]) +def test_export_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1760,10 +1740,6 @@ def test_export_model( assert isinstance(response, future.Future) -def test_export_model_from_dict(): - test_export_model(request_type=dict) - - def test_export_model_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. @@ -1960,9 +1936,10 @@ async def test_export_model_flattened_error_async(): ) -def test_get_model_evaluation( - transport: str = "grpc", request_type=model_service.GetModelEvaluationRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.GetModelEvaluationRequest, dict,] +) +def test_get_model_evaluation(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1995,10 +1972,6 @@ def test_get_model_evaluation( assert response.slice_dimensions == ["slice_dimensions_value"] -def test_get_model_evaluation_from_dict(): - test_get_model_evaluation(request_type=dict) - - def test_get_model_evaluation_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. @@ -2187,9 +2160,10 @@ async def test_get_model_evaluation_flattened_error_async(): ) -def test_list_model_evaluations( - transport: str = "grpc", request_type=model_service.ListModelEvaluationsRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.ListModelEvaluationsRequest, dict,] +) +def test_list_model_evaluations(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2218,10 +2192,6 @@ def test_list_model_evaluations( assert response.next_page_token == "next_page_token_value" -def test_list_model_evaluations_from_dict(): - test_list_model_evaluations(request_type=dict) - - def test_list_model_evaluations_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. @@ -2406,8 +2376,10 @@ async def test_list_model_evaluations_flattened_error_async(): ) -def test_list_model_evaluations_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluations_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2452,8 +2424,10 @@ def test_list_model_evaluations_pager(): assert all(isinstance(i, model_evaluation.ModelEvaluation) for i in results) -def test_list_model_evaluations_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluations_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2576,9 +2550,10 @@ async def test_list_model_evaluations_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_model_evaluation_slice( - transport: str = "grpc", request_type=model_service.GetModelEvaluationSliceRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.GetModelEvaluationSliceRequest, dict,] +) +def test_get_model_evaluation_slice(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2608,10 +2583,6 @@ def test_get_model_evaluation_slice( assert response.metrics_schema_uri == "metrics_schema_uri_value" -def test_get_model_evaluation_slice_from_dict(): - test_get_model_evaluation_slice(request_type=dict) - - def test_get_model_evaluation_slice_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. @@ -2797,9 +2768,10 @@ async def test_get_model_evaluation_slice_flattened_error_async(): ) -def test_list_model_evaluation_slices( - transport: str = "grpc", request_type=model_service.ListModelEvaluationSlicesRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.ListModelEvaluationSlicesRequest, dict,] +) +def test_list_model_evaluation_slices(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2828,10 +2800,6 @@ def test_list_model_evaluation_slices( assert response.next_page_token == "next_page_token_value" -def test_list_model_evaluation_slices_from_dict(): - test_list_model_evaluation_slices(request_type=dict) - - def test_list_model_evaluation_slices_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. @@ -3016,8 +2984,10 @@ async def test_list_model_evaluation_slices_flattened_error_async(): ) -def test_list_model_evaluation_slices_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluation_slices_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3066,8 +3036,10 @@ def test_list_model_evaluation_slices_pager(): ) -def test_list_model_evaluation_slices_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluation_slices_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3856,7 +3828,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/aiplatform_v1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py index 8889588489..19226e8658 100644 --- a/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py @@ -274,20 +274,20 @@ def test_pipeline_service_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, @@ -356,7 +356,7 @@ def test_pipeline_service_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 @@ -451,7 +451,7 @@ def test_pipeline_service_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, @@ -482,7 +482,7 @@ def test_pipeline_service_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", @@ -515,9 +515,10 @@ def test_pipeline_service_client_client_options_from_dict(): ) -def test_create_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.CreateTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CreateTrainingPipelineRequest, dict,] +) +def test_create_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -552,10 +553,6 @@ def test_create_training_pipeline( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED -def test_create_training_pipeline_from_dict(): - test_create_training_pipeline(request_type=dict) - - def test_create_training_pipeline_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. @@ -768,9 +765,10 @@ async def test_create_training_pipeline_flattened_error_async(): ) -def test_get_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.GetTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.GetTrainingPipelineRequest, dict,] +) +def test_get_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -805,10 +803,6 @@ def test_get_training_pipeline( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED -def test_get_training_pipeline_from_dict(): - test_get_training_pipeline(request_type=dict) - - def test_get_training_pipeline_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. @@ -1005,9 +999,10 @@ async def test_get_training_pipeline_flattened_error_async(): ) -def test_list_training_pipelines( - transport: str = "grpc", request_type=pipeline_service.ListTrainingPipelinesRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.ListTrainingPipelinesRequest, dict,] +) +def test_list_training_pipelines(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1036,10 +1031,6 @@ def test_list_training_pipelines( assert response.next_page_token == "next_page_token_value" -def test_list_training_pipelines_from_dict(): - test_list_training_pipelines(request_type=dict) - - def test_list_training_pipelines_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. @@ -1230,8 +1221,10 @@ async def test_list_training_pipelines_flattened_error_async(): ) -def test_list_training_pipelines_pager(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_training_pipelines_pager(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1276,8 +1269,10 @@ def test_list_training_pipelines_pager(): assert all(isinstance(i, training_pipeline.TrainingPipeline) for i in results) -def test_list_training_pipelines_pages(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_training_pipelines_pages(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1404,9 +1399,10 @@ async def test_list_training_pipelines_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.DeleteTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.DeleteTrainingPipelineRequest, dict,] +) +def test_delete_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1432,10 +1428,6 @@ def test_delete_training_pipeline( assert isinstance(response, future.Future) -def test_delete_training_pipeline_from_dict(): - test_delete_training_pipeline(request_type=dict) - - def test_delete_training_pipeline_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. @@ -1623,9 +1615,10 @@ async def test_delete_training_pipeline_flattened_error_async(): ) -def test_cancel_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.CancelTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CancelTrainingPipelineRequest, dict,] +) +def test_cancel_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1651,10 +1644,6 @@ def test_cancel_training_pipeline( assert response is None -def test_cancel_training_pipeline_from_dict(): - test_cancel_training_pipeline(request_type=dict) - - def test_cancel_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1836,9 +1825,10 @@ async def test_cancel_training_pipeline_flattened_error_async(): ) -def test_create_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.CreatePipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CreatePipelineJobRequest, dict,] +) +def test_create_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1875,10 +1865,6 @@ def test_create_pipeline_job( assert response.network == "network_value" -def test_create_pipeline_job_from_dict(): - test_create_pipeline_job(request_type=dict) - - def test_create_pipeline_job_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. @@ -2103,9 +2089,10 @@ async def test_create_pipeline_job_flattened_error_async(): ) -def test_get_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.GetPipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.GetPipelineJobRequest, dict,] +) +def test_get_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2140,10 +2127,6 @@ def test_get_pipeline_job( assert response.network == "network_value" -def test_get_pipeline_job_from_dict(): - test_get_pipeline_job(request_type=dict) - - def test_get_pipeline_job_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. @@ -2329,9 +2312,10 @@ async def test_get_pipeline_job_flattened_error_async(): ) -def test_list_pipeline_jobs( - transport: str = "grpc", request_type=pipeline_service.ListPipelineJobsRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.ListPipelineJobsRequest, dict,] +) +def test_list_pipeline_jobs(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2360,10 +2344,6 @@ def test_list_pipeline_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_pipeline_jobs_from_dict(): - test_list_pipeline_jobs(request_type=dict) - - def test_list_pipeline_jobs_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. @@ -2554,8 +2534,10 @@ async def test_list_pipeline_jobs_flattened_error_async(): ) -def test_list_pipeline_jobs_pager(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_pipeline_jobs_pager(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2596,8 +2578,10 @@ def test_list_pipeline_jobs_pager(): assert all(isinstance(i, pipeline_job.PipelineJob) for i in results) -def test_list_pipeline_jobs_pages(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_pipeline_jobs_pages(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2712,9 +2696,10 @@ async def test_list_pipeline_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.DeletePipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.DeletePipelineJobRequest, dict,] +) +def test_delete_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2740,10 +2725,6 @@ def test_delete_pipeline_job( assert isinstance(response, future.Future) -def test_delete_pipeline_job_from_dict(): - test_delete_pipeline_job(request_type=dict) - - def test_delete_pipeline_job_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. @@ -2931,9 +2912,10 @@ async def test_delete_pipeline_job_flattened_error_async(): ) -def test_cancel_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.CancelPipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CancelPipelineJobRequest, dict,] +) +def test_cancel_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2959,10 +2941,6 @@ def test_cancel_pipeline_job( assert response is None -def test_cancel_pipeline_job_from_dict(): - test_cancel_pipeline_job(request_type=dict) - - def test_cancel_pipeline_job_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. @@ -3911,7 +3889,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/aiplatform_v1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py index 8278921b19..aab0d4028c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_prediction_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py @@ -254,20 +254,20 @@ def test_prediction_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -336,7 +336,7 @@ def test_prediction_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -431,7 +431,7 @@ def test_prediction_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -462,7 +462,7 @@ def test_prediction_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -495,9 +495,8 @@ def test_prediction_service_client_client_options_from_dict(): ) -def test_predict( - transport: str = "grpc", request_type=prediction_service.PredictRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,]) +def test_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -528,10 +527,6 @@ def test_predict( assert response.model_display_name == "model_display_name_value" -def test_predict_from_dict(): - test_predict(request_type=dict) - - def test_predict_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,9 +667,8 @@ async def test_predict_flattened_error_async(): ) -def test_raw_predict( - transport: str = "grpc", request_type=prediction_service.RawPredictRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.RawPredictRequest, dict,]) +def test_raw_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -702,10 +696,6 @@ def test_raw_predict( assert response.data == b"data_blob" -def test_raw_predict_from_dict(): - test_raw_predict(request_type=dict) - - def test_raw_predict_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. @@ -898,9 +888,8 @@ async def test_raw_predict_flattened_error_async(): ) -def test_explain( - transport: str = "grpc", request_type=prediction_service.ExplainRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.ExplainRequest, dict,]) +def test_explain(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -927,10 +916,6 @@ def test_explain( assert response.deployed_model_id == "deployed_model_id_value" -def test_explain_from_dict(): - test_explain(request_type=dict) - - def test_explain_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. @@ -1609,7 +1594,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/aiplatform_v1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py index 4bf3404939..66f172cb7a 100644 --- a/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py @@ -263,20 +263,20 @@ def test_specialist_pool_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -345,7 +345,7 @@ def test_specialist_pool_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -444,7 +444,7 @@ def test_specialist_pool_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -479,7 +479,7 @@ def test_specialist_pool_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -512,10 +512,10 @@ def test_specialist_pool_service_client_client_options_from_dict(): ) -def test_create_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.CreateSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.CreateSpecialistPoolRequest, dict,] +) +def test_create_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -541,10 +541,6 @@ def test_create_specialist_pool( assert isinstance(response, future.Future) -def test_create_specialist_pool_from_dict(): - test_create_specialist_pool(request_type=dict) - - def test_create_specialist_pool_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. @@ -754,10 +750,10 @@ async def test_create_specialist_pool_flattened_error_async(): ) -def test_get_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.GetSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.GetSpecialistPoolRequest, dict,] +) +def test_get_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -796,10 +792,6 @@ def test_get_specialist_pool( assert response.specialist_worker_emails == ["specialist_worker_emails_value"] -def test_get_specialist_pool_from_dict(): - test_get_specialist_pool(request_type=dict) - - def test_get_specialist_pool_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. @@ -1006,10 +998,10 @@ async def test_get_specialist_pool_flattened_error_async(): ) -def test_list_specialist_pools( - transport: str = "grpc", - request_type=specialist_pool_service.ListSpecialistPoolsRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.ListSpecialistPoolsRequest, dict,] +) +def test_list_specialist_pools(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1038,10 +1030,6 @@ def test_list_specialist_pools( assert response.next_page_token == "next_page_token_value" -def test_list_specialist_pools_from_dict(): - test_list_specialist_pools(request_type=dict) - - def test_list_specialist_pools_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1238,9 +1226,9 @@ async def test_list_specialist_pools_flattened_error_async(): ) -def test_list_specialist_pools_pager(): +def test_list_specialist_pools_pager(transport_name: str = "grpc"): client = SpecialistPoolServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1286,9 +1274,9 @@ def test_list_specialist_pools_pager(): assert all(isinstance(i, specialist_pool.SpecialistPool) for i in results) -def test_list_specialist_pools_pages(): +def test_list_specialist_pools_pages(transport_name: str = "grpc"): client = SpecialistPoolServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1416,10 +1404,10 @@ async def test_list_specialist_pools_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.DeleteSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.DeleteSpecialistPoolRequest, dict,] +) +def test_delete_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1445,10 +1433,6 @@ def test_delete_specialist_pool( assert isinstance(response, future.Future) -def test_delete_specialist_pool_from_dict(): - test_delete_specialist_pool(request_type=dict) - - def test_delete_specialist_pool_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,10 +1626,10 @@ async def test_delete_specialist_pool_flattened_error_async(): ) -def test_update_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.UpdateSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.UpdateSpecialistPoolRequest, dict,] +) +def test_update_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1671,10 +1655,6 @@ def test_update_specialist_pool( assert isinstance(response, future.Future) -def test_update_specialist_pool_from_dict(): - test_update_specialist_pool(request_type=dict) - - def test_update_specialist_pool_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,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/aiplatform_v1/test_tensorboard_service.py b/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py index 0a5b116fe3..9e6da56f1f 100644 --- a/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py @@ -272,20 +272,20 @@ def test_tensorboard_service_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, @@ -354,7 +354,7 @@ def test_tensorboard_service_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 @@ -449,7 +449,7 @@ def test_tensorboard_service_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, @@ -480,7 +480,7 @@ def test_tensorboard_service_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", @@ -513,9 +513,10 @@ def test_tensorboard_service_client_client_options_from_dict(): ) -def test_create_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.CreateTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardRequest, dict,] +) +def test_create_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -541,10 +542,6 @@ def test_create_tensorboard( assert isinstance(response, future.Future) -def test_create_tensorboard_from_dict(): - test_create_tensorboard(request_type=dict) - - def test_create_tensorboard_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. @@ -754,9 +751,10 @@ async def test_create_tensorboard_flattened_error_async(): ) -def test_get_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardRequest, dict,] +) +def test_get_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -793,10 +791,6 @@ def test_get_tensorboard( assert response.etag == "etag_value" -def test_get_tensorboard_from_dict(): - test_get_tensorboard(request_type=dict) - - def test_get_tensorboard_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. @@ -991,9 +985,10 @@ async def test_get_tensorboard_flattened_error_async(): ) -def test_update_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.UpdateTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardRequest, dict,] +) +def test_update_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1019,10 +1014,6 @@ def test_update_tensorboard( assert isinstance(response, future.Future) -def test_update_tensorboard_from_dict(): - test_update_tensorboard(request_type=dict) - - def test_update_tensorboard_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. @@ -1236,9 +1227,10 @@ async def test_update_tensorboard_flattened_error_async(): ) -def test_list_tensorboards( - transport: str = "grpc", request_type=tensorboard_service.ListTensorboardsRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardsRequest, dict,] +) +def test_list_tensorboards(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1267,10 +1259,6 @@ def test_list_tensorboards( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboards_from_dict(): - test_list_tensorboards(request_type=dict) - - def test_list_tensorboards_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. @@ -1467,8 +1455,10 @@ async def test_list_tensorboards_flattened_error_async(): ) -def test_list_tensorboards_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboards_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1509,8 +1499,10 @@ def test_list_tensorboards_pager(): assert all(isinstance(i, tensorboard.Tensorboard) for i in results) -def test_list_tensorboards_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboards_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1625,9 +1617,10 @@ async def test_list_tensorboards_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.DeleteTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardRequest, dict,] +) +def test_delete_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1653,10 +1646,6 @@ def test_delete_tensorboard( assert isinstance(response, future.Future) -def test_delete_tensorboard_from_dict(): - test_delete_tensorboard(request_type=dict) - - def test_delete_tensorboard_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. @@ -1850,10 +1839,10 @@ async def test_delete_tensorboard_flattened_error_async(): ) -def test_create_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardExperimentRequest, dict,] +) +def test_create_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1890,10 +1879,6 @@ def test_create_tensorboard_experiment( assert response.source == "source_value" -def test_create_tensorboard_experiment_from_dict(): - test_create_tensorboard_experiment(request_type=dict) - - def test_create_tensorboard_experiment_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. @@ -2132,10 +2117,10 @@ async def test_create_tensorboard_experiment_flattened_error_async(): ) -def test_get_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.GetTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardExperimentRequest, dict,] +) +def test_get_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2172,10 +2157,6 @@ def test_get_tensorboard_experiment( assert response.source == "source_value" -def test_get_tensorboard_experiment_from_dict(): - test_get_tensorboard_experiment(request_type=dict) - - def test_get_tensorboard_experiment_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. @@ -2380,10 +2361,10 @@ async def test_get_tensorboard_experiment_flattened_error_async(): ) -def test_update_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardExperimentRequest, dict,] +) +def test_update_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2420,10 +2401,6 @@ def test_update_tensorboard_experiment( assert response.source == "source_value" -def test_update_tensorboard_experiment_from_dict(): - test_update_tensorboard_experiment(request_type=dict) - - def test_update_tensorboard_experiment_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. @@ -2658,10 +2635,10 @@ async def test_update_tensorboard_experiment_flattened_error_async(): ) -def test_list_tensorboard_experiments( - transport: str = "grpc", - request_type=tensorboard_service.ListTensorboardExperimentsRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardExperimentsRequest, dict,] +) +def test_list_tensorboard_experiments(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2690,10 +2667,6 @@ def test_list_tensorboard_experiments( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_experiments_from_dict(): - test_list_tensorboard_experiments(request_type=dict) - - def test_list_tensorboard_experiments_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. @@ -2892,8 +2865,10 @@ async def test_list_tensorboard_experiments_flattened_error_async(): ) -def test_list_tensorboard_experiments_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_experiments_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2942,8 +2917,10 @@ def test_list_tensorboard_experiments_pager(): ) -def test_list_tensorboard_experiments_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_experiments_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3081,10 +3058,10 @@ async def test_list_tensorboard_experiments_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardExperimentRequest, dict,] +) +def test_delete_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3110,10 +3087,6 @@ def test_delete_tensorboard_experiment( assert isinstance(response, future.Future) -def test_delete_tensorboard_experiment_from_dict(): - test_delete_tensorboard_experiment(request_type=dict) - - def test_delete_tensorboard_experiment_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. @@ -3307,10 +3280,10 @@ async def test_delete_tensorboard_experiment_flattened_error_async(): ) -def test_create_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardRunRequest, dict,] +) +def test_create_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3345,10 +3318,6 @@ def test_create_tensorboard_run( assert response.etag == "etag_value" -def test_create_tensorboard_run_from_dict(): - test_create_tensorboard_run(request_type=dict) - - def test_create_tensorboard_run_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. @@ -3577,10 +3546,10 @@ async def test_create_tensorboard_run_flattened_error_async(): ) -def test_batch_create_tensorboard_runs( - transport: str = "grpc", - request_type=tensorboard_service.BatchCreateTensorboardRunsRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.BatchCreateTensorboardRunsRequest, dict,] +) +def test_batch_create_tensorboard_runs(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3606,10 +3575,6 @@ def test_batch_create_tensorboard_runs( assert isinstance(response, tensorboard_service.BatchCreateTensorboardRunsResponse) -def test_batch_create_tensorboard_runs_from_dict(): - test_batch_create_tensorboard_runs(request_type=dict) - - def test_batch_create_tensorboard_runs_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. @@ -3831,9 +3796,10 @@ async def test_batch_create_tensorboard_runs_flattened_error_async(): ) -def test_get_tensorboard_run( - transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRunRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardRunRequest, dict,] +) +def test_get_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3868,10 +3834,6 @@ def test_get_tensorboard_run( assert response.etag == "etag_value" -def test_get_tensorboard_run_from_dict(): - test_get_tensorboard_run(request_type=dict) - - def test_get_tensorboard_run_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. @@ -4074,10 +4036,10 @@ async def test_get_tensorboard_run_flattened_error_async(): ) -def test_update_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardRunRequest, dict,] +) +def test_update_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4112,10 +4074,6 @@ def test_update_tensorboard_run( assert response.etag == "etag_value" -def test_update_tensorboard_run_from_dict(): - test_update_tensorboard_run(request_type=dict) - - def test_update_tensorboard_run_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. @@ -4340,9 +4298,10 @@ async def test_update_tensorboard_run_flattened_error_async(): ) -def test_list_tensorboard_runs( - transport: str = "grpc", request_type=tensorboard_service.ListTensorboardRunsRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardRunsRequest, dict,] +) +def test_list_tensorboard_runs(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4371,10 +4330,6 @@ def test_list_tensorboard_runs( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_runs_from_dict(): - test_list_tensorboard_runs(request_type=dict) - - def test_list_tensorboard_runs_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. @@ -4571,8 +4526,10 @@ async def test_list_tensorboard_runs_flattened_error_async(): ) -def test_list_tensorboard_runs_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_runs_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4617,8 +4574,10 @@ def test_list_tensorboard_runs_pager(): assert all(isinstance(i, tensorboard_run.TensorboardRun) for i in results) -def test_list_tensorboard_runs_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_runs_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4745,10 +4704,10 @@ async def test_list_tensorboard_runs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardRunRequest, dict,] +) +def test_delete_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4774,10 +4733,6 @@ def test_delete_tensorboard_run( assert isinstance(response, future.Future) -def test_delete_tensorboard_run_from_dict(): - test_delete_tensorboard_run(request_type=dict) - - def test_delete_tensorboard_run_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. @@ -4971,10 +4926,10 @@ async def test_delete_tensorboard_run_flattened_error_async(): ) -def test_batch_create_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.BatchCreateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.BatchCreateTensorboardTimeSeriesRequest, dict,] +) +def test_batch_create_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5004,10 +4959,6 @@ def test_batch_create_tensorboard_time_series( ) -def test_batch_create_tensorboard_time_series_from_dict(): - test_batch_create_tensorboard_time_series(request_type=dict) - - def test_batch_create_tensorboard_time_series_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. @@ -5249,10 +5200,10 @@ async def test_batch_create_tensorboard_time_series_flattened_error_async(): ) -def test_create_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardTimeSeriesRequest, dict,] +) +def test_create_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5296,10 +5247,6 @@ def test_create_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_create_tensorboard_time_series_from_dict(): - test_create_tensorboard_time_series(request_type=dict) - - def test_create_tensorboard_time_series_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. @@ -5535,10 +5482,10 @@ async def test_create_tensorboard_time_series_flattened_error_async(): ) -def test_get_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.GetTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardTimeSeriesRequest, dict,] +) +def test_get_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5582,10 +5529,6 @@ def test_get_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_get_tensorboard_time_series_from_dict(): - test_get_tensorboard_time_series(request_type=dict) - - def test_get_tensorboard_time_series_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. @@ -5797,10 +5740,10 @@ async def test_get_tensorboard_time_series_flattened_error_async(): ) -def test_update_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardTimeSeriesRequest, dict,] +) +def test_update_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5844,10 +5787,6 @@ def test_update_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_update_tensorboard_time_series_from_dict(): - test_update_tensorboard_time_series(request_type=dict) - - def test_update_tensorboard_time_series_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. @@ -6089,10 +6028,10 @@ async def test_update_tensorboard_time_series_flattened_error_async(): ) -def test_list_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.ListTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardTimeSeriesRequest, dict,] +) +def test_list_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6121,10 +6060,6 @@ def test_list_tensorboard_time_series( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_time_series_from_dict(): - test_list_tensorboard_time_series(request_type=dict) - - def test_list_tensorboard_time_series_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. @@ -6323,8 +6258,10 @@ async def test_list_tensorboard_time_series_flattened_error_async(): ) -def test_list_tensorboard_time_series_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_time_series_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6374,8 +6311,10 @@ def test_list_tensorboard_time_series_pager(): ) -def test_list_tensorboard_time_series_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_time_series_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6513,10 +6452,10 @@ async def test_list_tensorboard_time_series_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardTimeSeriesRequest, dict,] +) +def test_delete_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6542,10 +6481,6 @@ def test_delete_tensorboard_time_series( assert isinstance(response, future.Future) -def test_delete_tensorboard_time_series_from_dict(): - test_delete_tensorboard_time_series(request_type=dict) - - def test_delete_tensorboard_time_series_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. @@ -6739,10 +6674,11 @@ async def test_delete_tensorboard_time_series_flattened_error_async(): ) -def test_batch_read_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.BatchReadTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", + [tensorboard_service.BatchReadTensorboardTimeSeriesDataRequest, dict,], +) +def test_batch_read_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6774,10 +6710,6 @@ def test_batch_read_tensorboard_time_series_data( ) -def test_batch_read_tensorboard_time_series_data_from_dict(): - test_batch_read_tensorboard_time_series_data(request_type=dict) - - def test_batch_read_tensorboard_time_series_data_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. @@ -6987,10 +6919,10 @@ async def test_batch_read_tensorboard_time_series_data_flattened_error_async(): ) -def test_read_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.ReadTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ReadTensorboardTimeSeriesDataRequest, dict,] +) +def test_read_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7018,10 +6950,6 @@ def test_read_tensorboard_time_series_data( ) -def test_read_tensorboard_time_series_data_from_dict(): - test_read_tensorboard_time_series_data(request_type=dict) - - def test_read_tensorboard_time_series_data_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. @@ -7229,10 +7157,10 @@ async def test_read_tensorboard_time_series_data_flattened_error_async(): ) -def test_read_tensorboard_blob_data( - transport: str = "grpc", - request_type=tensorboard_service.ReadTensorboardBlobDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ReadTensorboardBlobDataRequest, dict,] +) +def test_read_tensorboard_blob_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7261,10 +7189,6 @@ def test_read_tensorboard_blob_data( assert isinstance(message, tensorboard_service.ReadTensorboardBlobDataResponse) -def test_read_tensorboard_blob_data_from_dict(): - test_read_tensorboard_blob_data(request_type=dict) - - def test_read_tensorboard_blob_data_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. @@ -7469,10 +7393,10 @@ async def test_read_tensorboard_blob_data_flattened_error_async(): ) -def test_write_tensorboard_experiment_data( - transport: str = "grpc", - request_type=tensorboard_service.WriteTensorboardExperimentDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.WriteTensorboardExperimentDataRequest, dict,] +) +def test_write_tensorboard_experiment_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7500,10 +7424,6 @@ def test_write_tensorboard_experiment_data( ) -def test_write_tensorboard_experiment_data_from_dict(): - test_write_tensorboard_experiment_data(request_type=dict) - - def test_write_tensorboard_experiment_data_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. @@ -7745,10 +7665,10 @@ async def test_write_tensorboard_experiment_data_flattened_error_async(): ) -def test_write_tensorboard_run_data( - transport: str = "grpc", - request_type=tensorboard_service.WriteTensorboardRunDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.WriteTensorboardRunDataRequest, dict,] +) +def test_write_tensorboard_run_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7774,10 +7694,6 @@ def test_write_tensorboard_run_data( assert isinstance(response, tensorboard_service.WriteTensorboardRunDataResponse) -def test_write_tensorboard_run_data_from_dict(): - test_write_tensorboard_run_data(request_type=dict) - - def test_write_tensorboard_run_data_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. @@ -8015,10 +7931,10 @@ async def test_write_tensorboard_run_data_flattened_error_async(): ) -def test_export_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.ExportTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ExportTensorboardTimeSeriesDataRequest, dict,] +) +def test_export_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -8047,10 +7963,6 @@ def test_export_tensorboard_time_series_data( assert response.next_page_token == "next_page_token_value" -def test_export_tensorboard_time_series_data_from_dict(): - test_export_tensorboard_time_series_data(request_type=dict) - - def test_export_tensorboard_time_series_data_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. @@ -8265,8 +8177,10 @@ async def test_export_tensorboard_time_series_data_flattened_error_async(): ) -def test_export_tensorboard_time_series_data_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_export_tensorboard_time_series_data_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8313,8 +8227,10 @@ def test_export_tensorboard_time_series_data_pager(): assert all(isinstance(i, tensorboard_data.TimeSeriesDataPoint) for i in results) -def test_export_tensorboard_time_series_data_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_export_tensorboard_time_series_data_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -9135,7 +9051,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/aiplatform_v1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py index 5050a30807..bfbab47d8c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_vizier_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py @@ -255,20 +255,20 @@ def test_vizier_service_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, @@ -327,7 +327,7 @@ def test_vizier_service_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 @@ -422,7 +422,7 @@ def test_vizier_service_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, @@ -453,7 +453,7 @@ def test_vizier_service_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", @@ -486,9 +486,8 @@ def test_vizier_service_client_client_options_from_dict(): ) -def test_create_study( - transport: str = "grpc", request_type=vizier_service.CreateStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CreateStudyRequest, dict,]) +def test_create_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -521,10 +520,6 @@ def test_create_study( assert response.inactive_reason == "inactive_reason_value" -def test_create_study_from_dict(): - test_create_study(request_type=dict) - - def test_create_study_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. @@ -718,9 +713,8 @@ async def test_create_study_flattened_error_async(): ) -def test_get_study( - transport: str = "grpc", request_type=vizier_service.GetStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.GetStudyRequest, dict,]) +def test_get_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -753,10 +747,6 @@ def test_get_study( assert response.inactive_reason == "inactive_reason_value" -def test_get_study_from_dict(): - test_get_study(request_type=dict) - - def test_get_study_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. @@ -936,9 +926,8 @@ async def test_get_study_flattened_error_async(): ) -def test_list_studies( - transport: str = "grpc", request_type=vizier_service.ListStudiesRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.ListStudiesRequest, dict,]) +def test_list_studies(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -965,10 +954,6 @@ def test_list_studies( assert response.next_page_token == "next_page_token_value" -def test_list_studies_from_dict(): - test_list_studies(request_type=dict) - - def test_list_studies_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. @@ -1144,8 +1129,10 @@ async def test_list_studies_flattened_error_async(): ) -def test_list_studies_pager(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_studies_pager(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_studies), "__call__") as call: @@ -1178,8 +1165,10 @@ def test_list_studies_pager(): assert all(isinstance(i, study.Study) for i in results) -def test_list_studies_pages(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_studies_pages(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_studies), "__call__") as call: @@ -1266,9 +1255,8 @@ async def test_list_studies_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_study( - transport: str = "grpc", request_type=vizier_service.DeleteStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.DeleteStudyRequest, dict,]) +def test_delete_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1292,10 +1280,6 @@ def test_delete_study( assert response is None -def test_delete_study_from_dict(): - test_delete_study(request_type=dict) - - def test_delete_study_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. @@ -1464,9 +1448,8 @@ async def test_delete_study_flattened_error_async(): ) -def test_lookup_study( - transport: str = "grpc", request_type=vizier_service.LookupStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.LookupStudyRequest, dict,]) +def test_lookup_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1499,10 +1482,6 @@ def test_lookup_study( assert response.inactive_reason == "inactive_reason_value" -def test_lookup_study_from_dict(): - test_lookup_study(request_type=dict) - - def test_lookup_study_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. @@ -1682,9 +1661,8 @@ async def test_lookup_study_flattened_error_async(): ) -def test_suggest_trials( - transport: str = "grpc", request_type=vizier_service.SuggestTrialsRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.SuggestTrialsRequest, dict,]) +def test_suggest_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1708,10 +1686,6 @@ def test_suggest_trials( assert isinstance(response, future.Future) -def test_suggest_trials_from_dict(): - test_suggest_trials(request_type=dict) - - def test_suggest_trials_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. @@ -1814,9 +1788,8 @@ async def test_suggest_trials_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_create_trial( - transport: str = "grpc", request_type=vizier_service.CreateTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CreateTrialRequest, dict,]) +def test_create_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1853,10 +1826,6 @@ def test_create_trial( assert response.custom_job == "custom_job_value" -def test_create_trial_from_dict(): - test_create_trial(request_type=dict) - - def test_create_trial_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. @@ -2054,9 +2023,8 @@ async def test_create_trial_flattened_error_async(): ) -def test_get_trial( - transport: str = "grpc", request_type=vizier_service.GetTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.GetTrialRequest, dict,]) +def test_get_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2093,10 +2061,6 @@ def test_get_trial( assert response.custom_job == "custom_job_value" -def test_get_trial_from_dict(): - test_get_trial(request_type=dict) - - def test_get_trial_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. @@ -2280,9 +2244,8 @@ async def test_get_trial_flattened_error_async(): ) -def test_list_trials( - transport: str = "grpc", request_type=vizier_service.ListTrialsRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.ListTrialsRequest, dict,]) +def test_list_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2309,10 +2272,6 @@ def test_list_trials( assert response.next_page_token == "next_page_token_value" -def test_list_trials_from_dict(): - test_list_trials(request_type=dict) - - def test_list_trials_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. @@ -2488,8 +2447,10 @@ async def test_list_trials_flattened_error_async(): ) -def test_list_trials_pager(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_trials_pager(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_trials), "__call__") as call: @@ -2520,8 +2481,10 @@ def test_list_trials_pager(): assert all(isinstance(i, study.Trial) for i in results) -def test_list_trials_pages(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_trials_pages(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_trials), "__call__") as call: @@ -2602,9 +2565,10 @@ async def test_list_trials_async_pages(): assert page_.raw_page.next_page_token == token -def test_add_trial_measurement( - transport: str = "grpc", request_type=vizier_service.AddTrialMeasurementRequest -): +@pytest.mark.parametrize( + "request_type", [vizier_service.AddTrialMeasurementRequest, dict,] +) +def test_add_trial_measurement(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2643,10 +2607,6 @@ def test_add_trial_measurement( assert response.custom_job == "custom_job_value" -def test_add_trial_measurement_from_dict(): - test_add_trial_measurement(request_type=dict) - - def test_add_trial_measurement_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. @@ -2769,9 +2729,8 @@ async def test_add_trial_measurement_field_headers_async(): assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] -def test_complete_trial( - transport: str = "grpc", request_type=vizier_service.CompleteTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CompleteTrialRequest, dict,]) +def test_complete_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2808,10 +2767,6 @@ def test_complete_trial( assert response.custom_job == "custom_job_value" -def test_complete_trial_from_dict(): - test_complete_trial(request_type=dict) - - def test_complete_trial_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. @@ -2925,9 +2880,8 @@ async def test_complete_trial_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_trial( - transport: str = "grpc", request_type=vizier_service.DeleteTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.DeleteTrialRequest, dict,]) +def test_delete_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2951,10 +2905,6 @@ def test_delete_trial( assert response is None -def test_delete_trial_from_dict(): - test_delete_trial(request_type=dict) - - def test_delete_trial_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. @@ -3123,10 +3073,10 @@ async def test_delete_trial_flattened_error_async(): ) -def test_check_trial_early_stopping_state( - transport: str = "grpc", - request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, -): +@pytest.mark.parametrize( + "request_type", [vizier_service.CheckTrialEarlyStoppingStateRequest, dict,] +) +def test_check_trial_early_stopping_state(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3152,10 +3102,6 @@ def test_check_trial_early_stopping_state( assert isinstance(response, future.Future) -def test_check_trial_early_stopping_state_from_dict(): - test_check_trial_early_stopping_state(request_type=dict) - - def test_check_trial_early_stopping_state_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. @@ -3267,9 +3213,8 @@ async def test_check_trial_early_stopping_state_field_headers_async(): assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] -def test_stop_trial( - transport: str = "grpc", request_type=vizier_service.StopTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.StopTrialRequest, dict,]) +def test_stop_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3306,10 +3251,6 @@ def test_stop_trial( assert response.custom_job == "custom_job_value" -def test_stop_trial_from_dict(): - test_stop_trial(request_type=dict) - - def test_stop_trial_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. @@ -3423,9 +3364,10 @@ async def test_stop_trial_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_list_optimal_trials( - transport: str = "grpc", request_type=vizier_service.ListOptimalTrialsRequest -): +@pytest.mark.parametrize( + "request_type", [vizier_service.ListOptimalTrialsRequest, dict,] +) +def test_list_optimal_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3451,10 +3393,6 @@ def test_list_optimal_trials( assert isinstance(response, vizier_service.ListOptimalTrialsResponse) -def test_list_optimal_trials_from_dict(): - test_list_optimal_trials(request_type=dict) - - def test_list_optimal_trials_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. @@ -4249,7 +4187,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/aiplatform_v1beta1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py index b3c8578507..d59b4eb1e6 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py @@ -265,20 +265,20 @@ def test_dataset_service_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, @@ -337,7 +337,7 @@ def test_dataset_service_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 @@ -432,7 +432,7 @@ def test_dataset_service_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, @@ -463,7 +463,7 @@ def test_dataset_service_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", @@ -496,9 +496,8 @@ def test_dataset_service_client_client_options_from_dict(): ) -def test_create_dataset( - transport: str = "grpc", request_type=dataset_service.CreateDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.CreateDatasetRequest, dict,]) +def test_create_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -522,10 +521,6 @@ def test_create_dataset( assert isinstance(response, future.Future) -def test_create_dataset_from_dict(): - test_create_dataset(request_type=dict) - - def test_create_dataset_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. @@ -714,9 +709,8 @@ async def test_create_dataset_flattened_error_async(): ) -def test_get_dataset( - transport: str = "grpc", request_type=dataset_service.GetDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.GetDatasetRequest, dict,]) +def test_get_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -751,10 +745,6 @@ def test_get_dataset( assert response.etag == "etag_value" -def test_get_dataset_from_dict(): - test_get_dataset(request_type=dict) - - def test_get_dataset_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. @@ -936,9 +926,8 @@ async def test_get_dataset_flattened_error_async(): ) -def test_update_dataset( - transport: str = "grpc", request_type=dataset_service.UpdateDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.UpdateDatasetRequest, dict,]) +def test_update_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -973,10 +962,6 @@ def test_update_dataset( assert response.etag == "etag_value" -def test_update_dataset_from_dict(): - test_update_dataset(request_type=dict) - - def test_update_dataset_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. @@ -1178,9 +1163,8 @@ async def test_update_dataset_flattened_error_async(): ) -def test_list_datasets( - transport: str = "grpc", request_type=dataset_service.ListDatasetsRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ListDatasetsRequest, dict,]) +def test_list_datasets(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1207,10 +1191,6 @@ def test_list_datasets( assert response.next_page_token == "next_page_token_value" -def test_list_datasets_from_dict(): - test_list_datasets(request_type=dict) - - def test_list_datasets_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. @@ -1388,8 +1368,10 @@ async def test_list_datasets_flattened_error_async(): ) -def test_list_datasets_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_datasets_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_datasets), "__call__") as call: @@ -1422,8 +1404,10 @@ def test_list_datasets_pager(): assert all(isinstance(i, dataset.Dataset) for i in results) -def test_list_datasets_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_datasets_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_datasets), "__call__") as call: @@ -1510,9 +1494,8 @@ async def test_list_datasets_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_dataset( - transport: str = "grpc", request_type=dataset_service.DeleteDatasetRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.DeleteDatasetRequest, dict,]) +def test_delete_dataset(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1536,10 +1519,6 @@ def test_delete_dataset( assert isinstance(response, future.Future) -def test_delete_dataset_from_dict(): - test_delete_dataset(request_type=dict) - - def test_delete_dataset_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. @@ -1714,9 +1693,8 @@ async def test_delete_dataset_flattened_error_async(): ) -def test_import_data( - transport: str = "grpc", request_type=dataset_service.ImportDataRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ImportDataRequest, dict,]) +def test_import_data(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1740,10 +1718,6 @@ def test_import_data( assert isinstance(response, future.Future) -def test_import_data_from_dict(): - test_import_data(request_type=dict) - - def test_import_data_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. @@ -1946,9 +1920,8 @@ async def test_import_data_flattened_error_async(): ) -def test_export_data( - transport: str = "grpc", request_type=dataset_service.ExportDataRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ExportDataRequest, dict,]) +def test_export_data(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1972,10 +1945,6 @@ def test_export_data( assert isinstance(response, future.Future) -def test_export_data_from_dict(): - test_export_data(request_type=dict) - - def test_export_data_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. @@ -2190,9 +2159,8 @@ async def test_export_data_flattened_error_async(): ) -def test_list_data_items( - transport: str = "grpc", request_type=dataset_service.ListDataItemsRequest -): +@pytest.mark.parametrize("request_type", [dataset_service.ListDataItemsRequest, dict,]) +def test_list_data_items(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2219,10 +2187,6 @@ def test_list_data_items( assert response.next_page_token == "next_page_token_value" -def test_list_data_items_from_dict(): - test_list_data_items(request_type=dict) - - def test_list_data_items_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. @@ -2400,8 +2364,10 @@ async def test_list_data_items_flattened_error_async(): ) -def test_list_data_items_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_items_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_data_items), "__call__") as call: @@ -2440,8 +2406,10 @@ def test_list_data_items_pager(): assert all(isinstance(i, data_item.DataItem) for i in results) -def test_list_data_items_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_items_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_data_items), "__call__") as call: @@ -2546,9 +2514,10 @@ async def test_list_data_items_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_annotation_spec( - transport: str = "grpc", request_type=dataset_service.GetAnnotationSpecRequest -): +@pytest.mark.parametrize( + "request_type", [dataset_service.GetAnnotationSpecRequest, dict,] +) +def test_get_annotation_spec(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2579,10 +2548,6 @@ def test_get_annotation_spec( assert response.etag == "etag_value" -def test_get_annotation_spec_from_dict(): - test_get_annotation_spec(request_type=dict) - - def test_get_annotation_spec_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. @@ -2775,9 +2740,10 @@ async def test_get_annotation_spec_flattened_error_async(): ) -def test_list_annotations( - transport: str = "grpc", request_type=dataset_service.ListAnnotationsRequest -): +@pytest.mark.parametrize( + "request_type", [dataset_service.ListAnnotationsRequest, dict,] +) +def test_list_annotations(request_type, transport: str = "grpc"): client = DatasetServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2804,10 +2770,6 @@ def test_list_annotations( assert response.next_page_token == "next_page_token_value" -def test_list_annotations_from_dict(): - test_list_annotations(request_type=dict) - - def test_list_annotations_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. @@ -2985,8 +2947,10 @@ async def test_list_annotations_flattened_error_async(): ) -def test_list_annotations_pager(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_annotations_pager(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_annotations), "__call__") as call: @@ -3025,8 +2989,10 @@ def test_list_annotations_pager(): assert all(isinstance(i, annotation.Annotation) for i in results) -def test_list_annotations_pages(): - client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_annotations_pages(transport_name: str = "grpc"): + client = DatasetServiceClient( + 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_annotations), "__call__") as call: @@ -3776,7 +3742,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/aiplatform_v1beta1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py index 7c59752cf7..c809a12289 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py @@ -266,20 +266,20 @@ def test_endpoint_service_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, @@ -348,7 +348,7 @@ def test_endpoint_service_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_endpoint_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -474,7 +474,7 @@ def test_endpoint_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -507,9 +507,10 @@ def test_endpoint_service_client_client_options_from_dict(): ) -def test_create_endpoint( - transport: str = "grpc", request_type=endpoint_service.CreateEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.CreateEndpointRequest, dict,] +) +def test_create_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -533,10 +534,6 @@ def test_create_endpoint( assert isinstance(response, future.Future) -def test_create_endpoint_from_dict(): - test_create_endpoint(request_type=dict) - - def test_create_endpoint_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. @@ -737,9 +734,8 @@ async def test_create_endpoint_flattened_error_async(): ) -def test_get_endpoint( - transport: str = "grpc", request_type=endpoint_service.GetEndpointRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.GetEndpointRequest, dict,]) +def test_get_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -781,10 +777,6 @@ def test_get_endpoint( ) -def test_get_endpoint_from_dict(): - test_get_endpoint(request_type=dict) - - def test_get_endpoint_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,9 +965,8 @@ async def test_get_endpoint_flattened_error_async(): ) -def test_list_endpoints( - transport: str = "grpc", request_type=endpoint_service.ListEndpointsRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.ListEndpointsRequest, dict,]) +def test_list_endpoints(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1002,10 +993,6 @@ def test_list_endpoints( assert response.next_page_token == "next_page_token_value" -def test_list_endpoints_from_dict(): - test_list_endpoints(request_type=dict) - - def test_list_endpoints_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,8 +1170,10 @@ async def test_list_endpoints_flattened_error_async(): ) -def test_list_endpoints_pager(): - client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pager(transport_name: str = "grpc"): + client = EndpointServiceClient( + 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_endpoints), "__call__") as call: @@ -1223,8 +1212,10 @@ def test_list_endpoints_pager(): assert all(isinstance(i, endpoint.Endpoint) for i in results) -def test_list_endpoints_pages(): - client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pages(transport_name: str = "grpc"): + client = EndpointServiceClient( + 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_endpoints), "__call__") as call: @@ -1333,9 +1324,10 @@ async def test_list_endpoints_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_endpoint( - transport: str = "grpc", request_type=endpoint_service.UpdateEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.UpdateEndpointRequest, dict,] +) +def test_update_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1377,10 +1369,6 @@ def test_update_endpoint( ) -def test_update_endpoint_from_dict(): - test_update_endpoint(request_type=dict) - - def test_update_endpoint_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 +1581,10 @@ async def test_update_endpoint_flattened_error_async(): ) -def test_delete_endpoint( - transport: str = "grpc", request_type=endpoint_service.DeleteEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [endpoint_service.DeleteEndpointRequest, dict,] +) +def test_delete_endpoint(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1619,10 +1608,6 @@ def test_delete_endpoint( assert isinstance(response, future.Future) -def test_delete_endpoint_from_dict(): - test_delete_endpoint(request_type=dict) - - def test_delete_endpoint_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. @@ -1797,9 +1782,8 @@ async def test_delete_endpoint_flattened_error_async(): ) -def test_deploy_model( - transport: str = "grpc", request_type=endpoint_service.DeployModelRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.DeployModelRequest, dict,]) +def test_deploy_model(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1823,10 +1807,6 @@ def test_deploy_model( assert isinstance(response, future.Future) -def test_deploy_model_from_dict(): - test_deploy_model(request_type=dict) - - def test_deploy_model_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. @@ -2063,9 +2043,8 @@ async def test_deploy_model_flattened_error_async(): ) -def test_undeploy_model( - transport: str = "grpc", request_type=endpoint_service.UndeployModelRequest -): +@pytest.mark.parametrize("request_type", [endpoint_service.UndeployModelRequest, dict,]) +def test_undeploy_model(request_type, transport: str = "grpc"): client = EndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2089,10 +2068,6 @@ def test_undeploy_model( assert isinstance(response, future.Future) -def test_undeploy_model_from_dict(): - test_undeploy_model(request_type=dict) - - def test_undeploy_model_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. @@ -2918,7 +2893,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/aiplatform_v1beta1/test_featurestore_online_serving_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py index 364971192d..7f35919008 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py @@ -284,20 +284,20 @@ def test_featurestore_online_serving_service_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, @@ -366,7 +366,7 @@ def test_featurestore_online_serving_service_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 @@ -465,7 +465,7 @@ def test_featurestore_online_serving_service_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, @@ -500,7 +500,7 @@ def test_featurestore_online_serving_service_client_client_options_credentials_f 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", @@ -533,10 +533,10 @@ def test_featurestore_online_serving_service_client_client_options_from_dict(): ) -def test_read_feature_values( - transport: str = "grpc", - request_type=featurestore_online_service.ReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_online_service.ReadFeatureValuesRequest, dict,] +) +def test_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreOnlineServingServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -562,10 +562,6 @@ def test_read_feature_values( assert isinstance(response, featurestore_online_service.ReadFeatureValuesResponse) -def test_read_feature_values_from_dict(): - test_read_feature_values(request_type=dict) - - def test_read_feature_values_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. @@ -761,10 +757,11 @@ async def test_read_feature_values_flattened_error_async(): ) -def test_streaming_read_feature_values( - transport: str = "grpc", - request_type=featurestore_online_service.StreamingReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", + [featurestore_online_service.StreamingReadFeatureValuesRequest, dict,], +) +def test_streaming_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreOnlineServingServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -797,10 +794,6 @@ def test_streaming_read_feature_values( ) -def test_streaming_read_feature_values_from_dict(): - test_streaming_read_feature_values(request_type=dict) - - def test_streaming_read_feature_values_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. @@ -1554,7 +1547,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/aiplatform_v1beta1/test_featurestore_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py index 392021dcb0..a57161b181 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py @@ -274,20 +274,20 @@ def test_featurestore_service_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, @@ -356,7 +356,7 @@ def test_featurestore_service_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 @@ -455,7 +455,7 @@ def test_featurestore_service_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, @@ -490,7 +490,7 @@ def test_featurestore_service_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", @@ -523,9 +523,10 @@ def test_featurestore_service_client_client_options_from_dict(): ) -def test_create_featurestore( - transport: str = "grpc", request_type=featurestore_service.CreateFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateFeaturestoreRequest, dict,] +) +def test_create_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -551,10 +552,6 @@ def test_create_featurestore( assert isinstance(response, future.Future) -def test_create_featurestore_from_dict(): - test_create_featurestore(request_type=dict) - - def test_create_featurestore_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. @@ -774,9 +771,10 @@ async def test_create_featurestore_flattened_error_async(): ) -def test_get_featurestore( - transport: str = "grpc", request_type=featurestore_service.GetFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetFeaturestoreRequest, dict,] +) +def test_get_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -807,10 +805,6 @@ def test_get_featurestore( assert response.state == featurestore.Featurestore.State.STABLE -def test_get_featurestore_from_dict(): - test_get_featurestore(request_type=dict) - - def test_get_featurestore_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. @@ -999,9 +993,10 @@ async def test_get_featurestore_flattened_error_async(): ) -def test_list_featurestores( - transport: str = "grpc", request_type=featurestore_service.ListFeaturestoresRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListFeaturestoresRequest, dict,] +) +def test_list_featurestores(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1030,10 +1025,6 @@ def test_list_featurestores( assert response.next_page_token == "next_page_token_value" -def test_list_featurestores_from_dict(): - test_list_featurestores(request_type=dict) - - def test_list_featurestores_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. @@ -1230,8 +1221,10 @@ async def test_list_featurestores_flattened_error_async(): ) -def test_list_featurestores_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_featurestores_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1275,8 +1268,10 @@ def test_list_featurestores_pager(): assert all(isinstance(i, featurestore.Featurestore) for i in results) -def test_list_featurestores_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_featurestores_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1400,9 +1395,10 @@ async def test_list_featurestores_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_featurestore( - transport: str = "grpc", request_type=featurestore_service.UpdateFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateFeaturestoreRequest, dict,] +) +def test_update_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1428,10 +1424,6 @@ def test_update_featurestore( assert isinstance(response, future.Future) -def test_update_featurestore_from_dict(): - test_update_featurestore(request_type=dict) - - def test_update_featurestore_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. @@ -1647,9 +1639,10 @@ async def test_update_featurestore_flattened_error_async(): ) -def test_delete_featurestore( - transport: str = "grpc", request_type=featurestore_service.DeleteFeaturestoreRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteFeaturestoreRequest, dict,] +) +def test_delete_featurestore(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1675,10 +1668,6 @@ def test_delete_featurestore( assert isinstance(response, future.Future) -def test_delete_featurestore_from_dict(): - test_delete_featurestore(request_type=dict) - - def test_delete_featurestore_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. @@ -1884,9 +1873,10 @@ async def test_delete_featurestore_flattened_error_async(): ) -def test_create_entity_type( - transport: str = "grpc", request_type=featurestore_service.CreateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateEntityTypeRequest, dict,] +) +def test_create_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1912,10 +1902,6 @@ def test_create_entity_type( assert isinstance(response, future.Future) -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. @@ -2135,9 +2121,10 @@ async def test_create_entity_type_flattened_error_async(): ) -def test_get_entity_type( - transport: str = "grpc", request_type=featurestore_service.GetEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetEntityTypeRequest, dict,] +) +def test_get_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2166,10 +2153,6 @@ def test_get_entity_type( assert response.etag == "etag_value" -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. @@ -2356,9 +2339,10 @@ async def test_get_entity_type_flattened_error_async(): ) -def test_list_entity_types( - transport: str = "grpc", request_type=featurestore_service.ListEntityTypesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListEntityTypesRequest, dict,] +) +def test_list_entity_types(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2387,10 +2371,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. @@ -2587,8 +2567,10 @@ async def test_list_entity_types_flattened_error_async(): ) -def test_list_entity_types_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2629,8 +2611,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 = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_entity_types_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2745,9 +2729,10 @@ async def test_list_entity_types_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_entity_type( - transport: str = "grpc", request_type=featurestore_service.UpdateEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateEntityTypeRequest, dict,] +) +def test_update_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2778,10 +2763,6 @@ def test_update_entity_type( assert response.etag == "etag_value" -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. @@ -3000,9 +2981,10 @@ async def test_update_entity_type_flattened_error_async(): ) -def test_delete_entity_type( - transport: str = "grpc", request_type=featurestore_service.DeleteEntityTypeRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteEntityTypeRequest, dict,] +) +def test_delete_entity_type(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3028,10 +3010,6 @@ def test_delete_entity_type( assert isinstance(response, future.Future) -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. @@ -3237,9 +3215,10 @@ async def test_delete_entity_type_flattened_error_async(): ) -def test_create_feature( - transport: str = "grpc", request_type=featurestore_service.CreateFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.CreateFeatureRequest, dict,] +) +def test_create_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3263,10 +3242,6 @@ def test_create_feature( assert isinstance(response, future.Future) -def test_create_feature_from_dict(): - test_create_feature(request_type=dict) - - def test_create_feature_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. @@ -3474,10 +3449,10 @@ async def test_create_feature_flattened_error_async(): ) -def test_batch_create_features( - transport: str = "grpc", - request_type=featurestore_service.BatchCreateFeaturesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.BatchCreateFeaturesRequest, dict,] +) +def test_batch_create_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3503,10 +3478,6 @@ def test_batch_create_features( assert isinstance(response, future.Future) -def test_batch_create_features_from_dict(): - test_batch_create_features(request_type=dict) - - def test_batch_create_features_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. @@ -3716,9 +3687,10 @@ async def test_batch_create_features_flattened_error_async(): ) -def test_get_feature( - transport: str = "grpc", request_type=featurestore_service.GetFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.GetFeatureRequest, dict,] +) +def test_get_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3751,10 +3723,6 @@ def test_get_feature( assert response.etag == "etag_value" -def test_get_feature_from_dict(): - test_get_feature(request_type=dict) - - def test_get_feature_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. @@ -3940,9 +3908,10 @@ async def test_get_feature_flattened_error_async(): ) -def test_list_features( - transport: str = "grpc", request_type=featurestore_service.ListFeaturesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ListFeaturesRequest, dict,] +) +def test_list_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3969,10 +3938,6 @@ def test_list_features( assert response.next_page_token == "next_page_token_value" -def test_list_features_from_dict(): - test_list_features(request_type=dict) - - def test_list_features_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. @@ -4157,8 +4122,10 @@ async def test_list_features_flattened_error_async(): ) -def test_list_features_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_features_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -4193,8 +4160,10 @@ def test_list_features_pager(): assert all(isinstance(i, feature.Feature) for i in results) -def test_list_features_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_features_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -4291,9 +4260,10 @@ async def test_list_features_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_feature( - transport: str = "grpc", request_type=featurestore_service.UpdateFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.UpdateFeatureRequest, dict,] +) +def test_update_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4326,10 +4296,6 @@ def test_update_feature( assert response.etag == "etag_value" -def test_update_feature_from_dict(): - test_update_feature(request_type=dict) - - def test_update_feature_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. @@ -4536,9 +4502,10 @@ async def test_update_feature_flattened_error_async(): ) -def test_delete_feature( - transport: str = "grpc", request_type=featurestore_service.DeleteFeatureRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.DeleteFeatureRequest, dict,] +) +def test_delete_feature(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4562,10 +4529,6 @@ def test_delete_feature( assert isinstance(response, future.Future) -def test_delete_feature_from_dict(): - test_delete_feature(request_type=dict) - - def test_delete_feature_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. @@ -4747,10 +4710,10 @@ async def test_delete_feature_flattened_error_async(): ) -def test_import_feature_values( - transport: str = "grpc", - request_type=featurestore_service.ImportFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ImportFeatureValuesRequest, dict,] +) +def test_import_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4776,10 +4739,6 @@ def test_import_feature_values( assert isinstance(response, future.Future) -def test_import_feature_values_from_dict(): - test_import_feature_values(request_type=dict) - - def test_import_feature_values_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. @@ -4975,10 +4934,10 @@ async def test_import_feature_values_flattened_error_async(): ) -def test_batch_read_feature_values( - transport: str = "grpc", - request_type=featurestore_service.BatchReadFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.BatchReadFeatureValuesRequest, dict,] +) +def test_batch_read_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5004,10 +4963,6 @@ def test_batch_read_feature_values( assert isinstance(response, future.Future) -def test_batch_read_feature_values_from_dict(): - test_batch_read_feature_values(request_type=dict) - - def test_batch_read_feature_values_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. @@ -5209,10 +5164,10 @@ async def test_batch_read_feature_values_flattened_error_async(): ) -def test_export_feature_values( - transport: str = "grpc", - request_type=featurestore_service.ExportFeatureValuesRequest, -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.ExportFeatureValuesRequest, dict,] +) +def test_export_feature_values(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5238,10 +5193,6 @@ def test_export_feature_values( assert isinstance(response, future.Future) -def test_export_feature_values_from_dict(): - test_export_feature_values(request_type=dict) - - def test_export_feature_values_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. @@ -5437,9 +5388,10 @@ async def test_export_feature_values_flattened_error_async(): ) -def test_search_features( - transport: str = "grpc", request_type=featurestore_service.SearchFeaturesRequest -): +@pytest.mark.parametrize( + "request_type", [featurestore_service.SearchFeaturesRequest, dict,] +) +def test_search_features(request_type, transport: str = "grpc"): client = FeaturestoreServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5466,10 +5418,6 @@ def test_search_features( assert response.next_page_token == "next_page_token_value" -def test_search_features_from_dict(): - test_search_features(request_type=dict) - - def test_search_features_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. @@ -5668,8 +5616,10 @@ async def test_search_features_flattened_error_async(): ) -def test_search_features_pager(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_features_pager(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -5704,8 +5654,10 @@ def test_search_features_pager(): assert all(isinstance(i, feature.Feature) for i in results) -def test_search_features_pages(): - client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_features_pages(transport_name: str = "grpc"): + client = FeaturestoreServiceClient( + 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_features), "__call__") as call: @@ -6437,7 +6389,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/aiplatform_v1beta1/test_index_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py index 9e96140fe4..5cce66bb1b 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py @@ -265,20 +265,20 @@ def test_index_endpoint_service_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, @@ -347,7 +347,7 @@ def test_index_endpoint_service_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 @@ -446,7 +446,7 @@ def test_index_endpoint_service_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, @@ -481,7 +481,7 @@ def test_index_endpoint_service_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", @@ -514,10 +514,10 @@ def test_index_endpoint_service_client_client_options_from_dict(): ) -def test_create_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.CreateIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.CreateIndexEndpointRequest, dict,] +) +def test_create_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -543,10 +543,6 @@ def test_create_index_endpoint( assert isinstance(response, future.Future) -def test_create_index_endpoint_from_dict(): - test_create_index_endpoint(request_type=dict) - - def test_create_index_endpoint_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. @@ -756,9 +752,10 @@ async def test_create_index_endpoint_flattened_error_async(): ) -def test_get_index_endpoint( - transport: str = "grpc", request_type=index_endpoint_service.GetIndexEndpointRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.GetIndexEndpointRequest, dict,] +) +def test_get_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -797,10 +794,6 @@ def test_get_index_endpoint( assert response.enable_private_service_connect is True -def test_get_index_endpoint_from_dict(): - test_get_index_endpoint(request_type=dict) - - def test_get_index_endpoint_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. @@ -1007,10 +1000,10 @@ async def test_get_index_endpoint_flattened_error_async(): ) -def test_list_index_endpoints( - transport: str = "grpc", - request_type=index_endpoint_service.ListIndexEndpointsRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.ListIndexEndpointsRequest, dict,] +) +def test_list_index_endpoints(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1039,10 +1032,6 @@ def test_list_index_endpoints( assert response.next_page_token == "next_page_token_value" -def test_list_index_endpoints_from_dict(): - test_list_index_endpoints(request_type=dict) - - def test_list_index_endpoints_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,9 @@ async def test_list_index_endpoints_flattened_error_async(): ) -def test_list_index_endpoints_pager(): +def test_list_index_endpoints_pager(transport_name: str = "grpc"): client = IndexEndpointServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1287,9 +1276,9 @@ def test_list_index_endpoints_pager(): assert all(isinstance(i, index_endpoint.IndexEndpoint) for i in results) -def test_list_index_endpoints_pages(): +def test_list_index_endpoints_pages(transport_name: str = "grpc"): client = IndexEndpointServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1417,10 +1406,10 @@ async def test_list_index_endpoints_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.UpdateIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.UpdateIndexEndpointRequest, dict,] +) +def test_update_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1459,10 +1448,6 @@ def test_update_index_endpoint( assert response.enable_private_service_connect is True -def test_update_index_endpoint_from_dict(): - test_update_index_endpoint(request_type=dict) - - def test_update_index_endpoint_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. @@ -1691,10 +1676,10 @@ async def test_update_index_endpoint_flattened_error_async(): ) -def test_delete_index_endpoint( - transport: str = "grpc", - request_type=index_endpoint_service.DeleteIndexEndpointRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.DeleteIndexEndpointRequest, dict,] +) +def test_delete_index_endpoint(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1720,10 +1705,6 @@ def test_delete_index_endpoint( assert isinstance(response, future.Future) -def test_delete_index_endpoint_from_dict(): - test_delete_index_endpoint(request_type=dict) - - def test_delete_index_endpoint_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. @@ -1917,9 +1898,10 @@ async def test_delete_index_endpoint_flattened_error_async(): ) -def test_deploy_index( - transport: str = "grpc", request_type=index_endpoint_service.DeployIndexRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.DeployIndexRequest, dict,] +) +def test_deploy_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1943,10 +1925,6 @@ def test_deploy_index( assert isinstance(response, future.Future) -def test_deploy_index_from_dict(): - test_deploy_index(request_type=dict) - - def test_deploy_index_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. @@ -2148,9 +2126,10 @@ async def test_deploy_index_flattened_error_async(): ) -def test_undeploy_index( - transport: str = "grpc", request_type=index_endpoint_service.UndeployIndexRequest -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.UndeployIndexRequest, dict,] +) +def test_undeploy_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2174,10 +2153,6 @@ def test_undeploy_index( assert isinstance(response, future.Future) -def test_undeploy_index_from_dict(): - test_undeploy_index(request_type=dict) - - def test_undeploy_index_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. @@ -2379,10 +2354,10 @@ async def test_undeploy_index_flattened_error_async(): ) -def test_mutate_deployed_index( - transport: str = "grpc", - request_type=index_endpoint_service.MutateDeployedIndexRequest, -): +@pytest.mark.parametrize( + "request_type", [index_endpoint_service.MutateDeployedIndexRequest, dict,] +) +def test_mutate_deployed_index(request_type, transport: str = "grpc"): client = IndexEndpointServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2408,10 +2383,6 @@ def test_mutate_deployed_index( assert isinstance(response, future.Future) -def test_mutate_deployed_index_from_dict(): - test_mutate_deployed_index(request_type=dict) - - def test_mutate_deployed_index_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. @@ -3207,7 +3178,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/aiplatform_v1beta1/test_index_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py index f54ca8e4ca..fc0f3ffe99 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py @@ -250,20 +250,20 @@ def test_index_service_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_index_service_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_index_service_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_index_service_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,8 @@ def test_index_service_client_client_options_from_dict(): ) -def test_create_index( - transport: str = "grpc", request_type=index_service.CreateIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.CreateIndexRequest, dict,]) +def test_create_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -503,10 +502,6 @@ def test_create_index( assert isinstance(response, future.Future) -def test_create_index_from_dict(): - test_create_index(request_type=dict) - - def test_create_index_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. @@ -689,7 +684,8 @@ async def test_create_index_flattened_error_async(): ) -def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexRequest): +@pytest.mark.parametrize("request_type", [index_service.GetIndexRequest, dict,]) +def test_get_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -724,10 +720,6 @@ def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexR assert response.etag == "etag_value" -def test_get_index_from_dict(): - test_get_index(request_type=dict) - - def test_get_index_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. @@ -903,9 +895,8 @@ async def test_get_index_flattened_error_async(): ) -def test_list_indexes( - transport: str = "grpc", request_type=index_service.ListIndexesRequest -): +@pytest.mark.parametrize("request_type", [index_service.ListIndexesRequest, dict,]) +def test_list_indexes(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -932,10 +923,6 @@ def test_list_indexes( assert response.next_page_token == "next_page_token_value" -def test_list_indexes_from_dict(): - test_list_indexes(request_type=dict) - - def test_list_indexes_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. @@ -1105,8 +1092,10 @@ async def test_list_indexes_flattened_error_async(): ) -def test_list_indexes_pager(): - client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_indexes_pager(transport_name: str = "grpc"): + client = IndexServiceClient( + 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_indexes), "__call__") as call: @@ -1137,8 +1126,10 @@ def test_list_indexes_pager(): assert all(isinstance(i, index.Index) for i in results) -def test_list_indexes_pages(): - client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_indexes_pages(transport_name: str = "grpc"): + client = IndexServiceClient( + 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_indexes), "__call__") as call: @@ -1219,9 +1210,8 @@ async def test_list_indexes_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_index( - transport: str = "grpc", request_type=index_service.UpdateIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.UpdateIndexRequest, dict,]) +def test_update_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1245,10 +1235,6 @@ def test_update_index( assert isinstance(response, future.Future) -def test_update_index_from_dict(): - test_update_index(request_type=dict) - - def test_update_index_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. @@ -1433,9 +1419,8 @@ async def test_update_index_flattened_error_async(): ) -def test_delete_index( - transport: str = "grpc", request_type=index_service.DeleteIndexRequest -): +@pytest.mark.parametrize("request_type", [index_service.DeleteIndexRequest, dict,]) +def test_delete_index(request_type, transport: str = "grpc"): client = IndexServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1459,10 +1444,6 @@ def test_delete_index( assert isinstance(response, future.Future) -def test_delete_index_from_dict(): - test_delete_index(request_type=dict) - - def test_delete_index_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. @@ -2193,7 +2174,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/aiplatform_v1beta1/test_job_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py index 4538fb5fbe..63277c06f5 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py @@ -281,20 +281,20 @@ def test_job_service_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, @@ -351,7 +351,7 @@ def test_job_service_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 @@ -446,7 +446,7 @@ def test_job_service_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_job_service_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", @@ -508,9 +508,8 @@ def test_job_service_client_client_options_from_dict(): ) -def test_create_custom_job( - transport: str = "grpc", request_type=job_service.CreateCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.CreateCustomJobRequest, dict,]) +def test_create_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -543,10 +542,6 @@ def test_create_custom_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_custom_job_from_dict(): - test_create_custom_job(request_type=dict) - - def test_create_custom_job_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. @@ -750,9 +745,8 @@ async def test_create_custom_job_flattened_error_async(): ) -def test_get_custom_job( - transport: str = "grpc", request_type=job_service.GetCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.GetCustomJobRequest, dict,]) +def test_get_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -783,10 +777,6 @@ def test_get_custom_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_custom_job_from_dict(): - test_get_custom_job(request_type=dict) - - def test_get_custom_job_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. @@ -962,9 +952,8 @@ async def test_get_custom_job_flattened_error_async(): ) -def test_list_custom_jobs( - transport: str = "grpc", request_type=job_service.ListCustomJobsRequest -): +@pytest.mark.parametrize("request_type", [job_service.ListCustomJobsRequest, dict,]) +def test_list_custom_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -991,10 +980,6 @@ def test_list_custom_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_custom_jobs_from_dict(): - test_list_custom_jobs(request_type=dict) - - def test_list_custom_jobs_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. @@ -1164,8 +1149,10 @@ async def test_list_custom_jobs_flattened_error_async(): ) -def test_list_custom_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_custom_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + 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_custom_jobs), "__call__") as call: @@ -1202,8 +1189,10 @@ def test_list_custom_jobs_pager(): assert all(isinstance(i, custom_job.CustomJob) for i in results) -def test_list_custom_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_custom_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + 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_custom_jobs), "__call__") as call: @@ -1302,9 +1291,8 @@ async def test_list_custom_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_custom_job( - transport: str = "grpc", request_type=job_service.DeleteCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.DeleteCustomJobRequest, dict,]) +def test_delete_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1330,10 +1318,6 @@ def test_delete_custom_job( assert isinstance(response, future.Future) -def test_delete_custom_job_from_dict(): - test_delete_custom_job(request_type=dict) - - def test_delete_custom_job_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. @@ -1514,9 +1498,8 @@ async def test_delete_custom_job_flattened_error_async(): ) -def test_cancel_custom_job( - transport: str = "grpc", request_type=job_service.CancelCustomJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.CancelCustomJobRequest, dict,]) +def test_cancel_custom_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1542,10 +1525,6 @@ def test_cancel_custom_job( assert response is None -def test_cancel_custom_job_from_dict(): - test_cancel_custom_job(request_type=dict) - - def test_cancel_custom_job_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. @@ -1720,9 +1699,10 @@ async def test_cancel_custom_job_flattened_error_async(): ) -def test_create_data_labeling_job( - transport: str = "grpc", request_type=job_service.CreateDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateDataLabelingJobRequest, dict,] +) +def test_create_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1767,10 +1747,6 @@ def test_create_data_labeling_job( assert response.specialist_pools == ["specialist_pools_value"] -def test_create_data_labeling_job_from_dict(): - test_create_data_labeling_job(request_type=dict) - - def test_create_data_labeling_job_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. @@ -1987,9 +1963,8 @@ async def test_create_data_labeling_job_flattened_error_async(): ) -def test_get_data_labeling_job( - transport: str = "grpc", request_type=job_service.GetDataLabelingJobRequest -): +@pytest.mark.parametrize("request_type", [job_service.GetDataLabelingJobRequest, dict,]) +def test_get_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2034,10 +2009,6 @@ def test_get_data_labeling_job( assert response.specialist_pools == ["specialist_pools_value"] -def test_get_data_labeling_job_from_dict(): - test_get_data_labeling_job(request_type=dict) - - def test_get_data_labeling_job_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. @@ -2237,9 +2208,10 @@ async def test_get_data_labeling_job_flattened_error_async(): ) -def test_list_data_labeling_jobs( - transport: str = "grpc", request_type=job_service.ListDataLabelingJobsRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.ListDataLabelingJobsRequest, dict,] +) +def test_list_data_labeling_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2268,10 +2240,6 @@ def test_list_data_labeling_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_data_labeling_jobs_from_dict(): - test_list_data_labeling_jobs(request_type=dict) - - def test_list_data_labeling_jobs_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. @@ -2456,8 +2424,10 @@ async def test_list_data_labeling_jobs_flattened_error_async(): ) -def test_list_data_labeling_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_labeling_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2502,8 +2472,10 @@ def test_list_data_labeling_jobs_pager(): assert all(isinstance(i, data_labeling_job.DataLabelingJob) for i in results) -def test_list_data_labeling_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_labeling_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2626,9 +2598,10 @@ async def test_list_data_labeling_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_data_labeling_job( - transport: str = "grpc", request_type=job_service.DeleteDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteDataLabelingJobRequest, dict,] +) +def test_delete_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2654,10 +2627,6 @@ def test_delete_data_labeling_job( assert isinstance(response, future.Future) -def test_delete_data_labeling_job_from_dict(): - test_delete_data_labeling_job(request_type=dict) - - def test_delete_data_labeling_job_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. @@ -2839,9 +2808,10 @@ async def test_delete_data_labeling_job_flattened_error_async(): ) -def test_cancel_data_labeling_job( - transport: str = "grpc", request_type=job_service.CancelDataLabelingJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelDataLabelingJobRequest, dict,] +) +def test_cancel_data_labeling_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2867,10 +2837,6 @@ def test_cancel_data_labeling_job( assert response is None -def test_cancel_data_labeling_job_from_dict(): - test_cancel_data_labeling_job(request_type=dict) - - def test_cancel_data_labeling_job_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. @@ -3046,10 +3012,10 @@ async def test_cancel_data_labeling_job_flattened_error_async(): ) -def test_create_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.CreateHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateHyperparameterTuningJobRequest, dict,] +) +def test_create_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3088,10 +3054,6 @@ def test_create_hyperparameter_tuning_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_hyperparameter_tuning_job_from_dict(): - test_create_hyperparameter_tuning_job(request_type=dict) - - def test_create_hyperparameter_tuning_job_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. @@ -3314,9 +3276,10 @@ async def test_create_hyperparameter_tuning_job_flattened_error_async(): ) -def test_get_hyperparameter_tuning_job( - transport: str = "grpc", request_type=job_service.GetHyperparameterTuningJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.GetHyperparameterTuningJobRequest, dict,] +) +def test_get_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3355,10 +3318,6 @@ def test_get_hyperparameter_tuning_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_hyperparameter_tuning_job_from_dict(): - test_get_hyperparameter_tuning_job(request_type=dict) - - def test_get_hyperparameter_tuning_job_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. @@ -3553,10 +3512,10 @@ async def test_get_hyperparameter_tuning_job_flattened_error_async(): ) -def test_list_hyperparameter_tuning_jobs( - transport: str = "grpc", - request_type=job_service.ListHyperparameterTuningJobsRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ListHyperparameterTuningJobsRequest, dict,] +) +def test_list_hyperparameter_tuning_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3585,10 +3544,6 @@ def test_list_hyperparameter_tuning_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_hyperparameter_tuning_jobs_from_dict(): - test_list_hyperparameter_tuning_jobs(request_type=dict) - - def test_list_hyperparameter_tuning_jobs_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. @@ -3773,8 +3728,10 @@ async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): ) -def test_list_hyperparameter_tuning_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_hyperparameter_tuning_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3824,8 +3781,10 @@ def test_list_hyperparameter_tuning_jobs_pager(): ) -def test_list_hyperparameter_tuning_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_hyperparameter_tuning_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3959,10 +3918,10 @@ async def test_list_hyperparameter_tuning_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.DeleteHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteHyperparameterTuningJobRequest, dict,] +) +def test_delete_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3988,10 +3947,6 @@ def test_delete_hyperparameter_tuning_job( assert isinstance(response, future.Future) -def test_delete_hyperparameter_tuning_job_from_dict(): - test_delete_hyperparameter_tuning_job(request_type=dict) - - def test_delete_hyperparameter_tuning_job_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. @@ -4173,10 +4128,10 @@ async def test_delete_hyperparameter_tuning_job_flattened_error_async(): ) -def test_cancel_hyperparameter_tuning_job( - transport: str = "grpc", - request_type=job_service.CancelHyperparameterTuningJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelHyperparameterTuningJobRequest, dict,] +) +def test_cancel_hyperparameter_tuning_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4202,10 +4157,6 @@ def test_cancel_hyperparameter_tuning_job( assert response is None -def test_cancel_hyperparameter_tuning_job_from_dict(): - test_cancel_hyperparameter_tuning_job(request_type=dict) - - def test_cancel_hyperparameter_tuning_job_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. @@ -4381,9 +4332,10 @@ async def test_cancel_hyperparameter_tuning_job_flattened_error_async(): ) -def test_create_batch_prediction_job( - transport: str = "grpc", request_type=job_service.CreateBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateBatchPredictionJobRequest, dict,] +) +def test_create_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4420,10 +4372,6 @@ def test_create_batch_prediction_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_create_batch_prediction_job_from_dict(): - test_create_batch_prediction_job(request_type=dict) - - def test_create_batch_prediction_job_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. @@ -4640,9 +4588,10 @@ async def test_create_batch_prediction_job_flattened_error_async(): ) -def test_get_batch_prediction_job( - transport: str = "grpc", request_type=job_service.GetBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.GetBatchPredictionJobRequest, dict,] +) +def test_get_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4679,10 +4628,6 @@ def test_get_batch_prediction_job( assert response.state == job_state.JobState.JOB_STATE_QUEUED -def test_get_batch_prediction_job_from_dict(): - test_get_batch_prediction_job(request_type=dict) - - def test_get_batch_prediction_job_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. @@ -4875,9 +4820,10 @@ async def test_get_batch_prediction_job_flattened_error_async(): ) -def test_list_batch_prediction_jobs( - transport: str = "grpc", request_type=job_service.ListBatchPredictionJobsRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.ListBatchPredictionJobsRequest, dict,] +) +def test_list_batch_prediction_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4906,10 +4852,6 @@ def test_list_batch_prediction_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_batch_prediction_jobs_from_dict(): - test_list_batch_prediction_jobs(request_type=dict) - - def test_list_batch_prediction_jobs_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. @@ -5094,8 +5036,10 @@ async def test_list_batch_prediction_jobs_flattened_error_async(): ) -def test_list_batch_prediction_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_batch_prediction_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5142,8 +5086,10 @@ def test_list_batch_prediction_jobs_pager(): ) -def test_list_batch_prediction_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_batch_prediction_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5268,9 +5214,10 @@ async def test_list_batch_prediction_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_batch_prediction_job( - transport: str = "grpc", request_type=job_service.DeleteBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteBatchPredictionJobRequest, dict,] +) +def test_delete_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5296,10 +5243,6 @@ def test_delete_batch_prediction_job( assert isinstance(response, future.Future) -def test_delete_batch_prediction_job_from_dict(): - test_delete_batch_prediction_job(request_type=dict) - - def test_delete_batch_prediction_job_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. @@ -5481,9 +5424,10 @@ async def test_delete_batch_prediction_job_flattened_error_async(): ) -def test_cancel_batch_prediction_job( - transport: str = "grpc", request_type=job_service.CancelBatchPredictionJobRequest -): +@pytest.mark.parametrize( + "request_type", [job_service.CancelBatchPredictionJobRequest, dict,] +) +def test_cancel_batch_prediction_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5509,10 +5453,6 @@ def test_cancel_batch_prediction_job( assert response is None -def test_cancel_batch_prediction_job_from_dict(): - test_cancel_batch_prediction_job(request_type=dict) - - def test_cancel_batch_prediction_job_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. @@ -5688,10 +5628,10 @@ async def test_cancel_batch_prediction_job_flattened_error_async(): ) -def test_create_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.CreateModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.CreateModelDeploymentMonitoringJobRequest, dict,] +) +def test_create_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5739,10 +5679,6 @@ def test_create_model_deployment_monitoring_job( assert response.enable_monitoring_pipeline_logs is True -def test_create_model_deployment_monitoring_job_from_dict(): - test_create_model_deployment_monitoring_job(request_type=dict) - - def test_create_model_deployment_monitoring_job_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. @@ -5980,9 +5916,12 @@ async def test_create_model_deployment_monitoring_job_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict,], +) def test_search_model_deployment_monitoring_stats_anomalies( - transport: str = "grpc", - request_type=job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, + request_type, transport: str = "grpc" ): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, @@ -6018,10 +5957,6 @@ def test_search_model_deployment_monitoring_stats_anomalies( assert response.next_page_token == "next_page_token_value" -def test_search_model_deployment_monitoring_stats_anomalies_from_dict(): - test_search_model_deployment_monitoring_stats_anomalies(request_type=dict) - - def test_search_model_deployment_monitoring_stats_anomalies_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. @@ -6252,8 +6187,12 @@ async def test_search_model_deployment_monitoring_stats_anomalies_flattened_erro ) -def test_search_model_deployment_monitoring_stats_anomalies_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_model_deployment_monitoring_stats_anomalies_pager( + transport_name: str = "grpc", +): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6308,8 +6247,12 @@ def test_search_model_deployment_monitoring_stats_anomalies_pager(): ) -def test_search_model_deployment_monitoring_stats_anomalies_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_model_deployment_monitoring_stats_anomalies_pages( + transport_name: str = "grpc", +): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6450,10 +6393,10 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.GetModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.GetModelDeploymentMonitoringJobRequest, dict,] +) +def test_get_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6501,10 +6444,6 @@ def test_get_model_deployment_monitoring_job( assert response.enable_monitoring_pipeline_logs is True -def test_get_model_deployment_monitoring_job_from_dict(): - test_get_model_deployment_monitoring_job(request_type=dict) - - def test_get_model_deployment_monitoring_job_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. @@ -6714,10 +6653,10 @@ async def test_get_model_deployment_monitoring_job_flattened_error_async(): ) -def test_list_model_deployment_monitoring_jobs( - transport: str = "grpc", - request_type=job_service.ListModelDeploymentMonitoringJobsRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ListModelDeploymentMonitoringJobsRequest, dict,] +) +def test_list_model_deployment_monitoring_jobs(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6746,10 +6685,6 @@ def test_list_model_deployment_monitoring_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_model_deployment_monitoring_jobs_from_dict(): - test_list_model_deployment_monitoring_jobs(request_type=dict) - - def test_list_model_deployment_monitoring_jobs_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. @@ -6938,8 +6873,10 @@ async def test_list_model_deployment_monitoring_jobs_flattened_error_async(): ) -def test_list_model_deployment_monitoring_jobs_pager(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_deployment_monitoring_jobs_pager(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6989,8 +6926,10 @@ def test_list_model_deployment_monitoring_jobs_pager(): ) -def test_list_model_deployment_monitoring_jobs_pages(): - client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_deployment_monitoring_jobs_pages(transport_name: str = "grpc"): + client = JobServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7124,10 +7063,10 @@ async def test_list_model_deployment_monitoring_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.UpdateModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.UpdateModelDeploymentMonitoringJobRequest, dict,] +) +def test_update_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7153,10 +7092,6 @@ def test_update_model_deployment_monitoring_job( assert isinstance(response, future.Future) -def test_update_model_deployment_monitoring_job_from_dict(): - test_update_model_deployment_monitoring_job(request_type=dict) - - def test_update_model_deployment_monitoring_job_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. @@ -7376,10 +7311,10 @@ async def test_update_model_deployment_monitoring_job_flattened_error_async(): ) -def test_delete_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.DeleteModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.DeleteModelDeploymentMonitoringJobRequest, dict,] +) +def test_delete_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7405,10 +7340,6 @@ def test_delete_model_deployment_monitoring_job( assert isinstance(response, future.Future) -def test_delete_model_deployment_monitoring_job_from_dict(): - test_delete_model_deployment_monitoring_job(request_type=dict) - - def test_delete_model_deployment_monitoring_job_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. @@ -7592,10 +7523,10 @@ async def test_delete_model_deployment_monitoring_job_flattened_error_async(): ) -def test_pause_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.PauseModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.PauseModelDeploymentMonitoringJobRequest, dict,] +) +def test_pause_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7621,10 +7552,6 @@ def test_pause_model_deployment_monitoring_job( assert response is None -def test_pause_model_deployment_monitoring_job_from_dict(): - test_pause_model_deployment_monitoring_job(request_type=dict) - - def test_pause_model_deployment_monitoring_job_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. @@ -7802,10 +7729,10 @@ async def test_pause_model_deployment_monitoring_job_flattened_error_async(): ) -def test_resume_model_deployment_monitoring_job( - transport: str = "grpc", - request_type=job_service.ResumeModelDeploymentMonitoringJobRequest, -): +@pytest.mark.parametrize( + "request_type", [job_service.ResumeModelDeploymentMonitoringJobRequest, dict,] +) +def test_resume_model_deployment_monitoring_job(request_type, transport: str = "grpc"): client = JobServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7831,10 +7758,6 @@ def test_resume_model_deployment_monitoring_job( assert response is None -def test_resume_model_deployment_monitoring_job_from_dict(): - test_resume_model_deployment_monitoring_job(request_type=dict) - - def test_resume_model_deployment_monitoring_job_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. @@ -8819,7 +8742,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/aiplatform_v1beta1/test_metadata_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py index 1407bbd817..fce386e262 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py @@ -271,20 +271,20 @@ def test_metadata_service_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, @@ -353,7 +353,7 @@ def test_metadata_service_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 @@ -448,7 +448,7 @@ def test_metadata_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -479,7 +479,7 @@ def test_metadata_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -512,9 +512,10 @@ def test_metadata_service_client_client_options_from_dict(): ) -def test_create_metadata_store( - transport: str = "grpc", request_type=metadata_service.CreateMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateMetadataStoreRequest, dict,] +) +def test_create_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -540,10 +541,6 @@ def test_create_metadata_store( assert isinstance(response, future.Future) -def test_create_metadata_store_from_dict(): - test_create_metadata_store(request_type=dict) - - def test_create_metadata_store_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. @@ -757,9 +754,10 @@ async def test_create_metadata_store_flattened_error_async(): ) -def test_get_metadata_store( - transport: str = "grpc", request_type=metadata_service.GetMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.GetMetadataStoreRequest, dict,] +) +def test_get_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -789,10 +787,6 @@ def test_get_metadata_store( assert response.description == "description_value" -def test_get_metadata_store_from_dict(): - test_get_metadata_store(request_type=dict) - - def test_get_metadata_store_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. @@ -984,9 +978,10 @@ async def test_get_metadata_store_flattened_error_async(): ) -def test_list_metadata_stores( - transport: str = "grpc", request_type=metadata_service.ListMetadataStoresRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListMetadataStoresRequest, dict,] +) +def test_list_metadata_stores(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1015,10 +1010,6 @@ def test_list_metadata_stores( assert response.next_page_token == "next_page_token_value" -def test_list_metadata_stores_from_dict(): - test_list_metadata_stores(request_type=dict) - - def test_list_metadata_stores_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. @@ -1209,8 +1200,10 @@ async def test_list_metadata_stores_flattened_error_async(): ) -def test_list_metadata_stores_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_stores_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1255,8 +1248,10 @@ def test_list_metadata_stores_pager(): assert all(isinstance(i, metadata_store.MetadataStore) for i in results) -def test_list_metadata_stores_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_stores_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1383,9 +1378,10 @@ async def test_list_metadata_stores_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_metadata_store( - transport: str = "grpc", request_type=metadata_service.DeleteMetadataStoreRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteMetadataStoreRequest, dict,] +) +def test_delete_metadata_store(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1411,10 +1407,6 @@ def test_delete_metadata_store( assert isinstance(response, future.Future) -def test_delete_metadata_store_from_dict(): - test_delete_metadata_store(request_type=dict) - - def test_delete_metadata_store_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. @@ -1602,9 +1594,10 @@ async def test_delete_metadata_store_flattened_error_async(): ) -def test_create_artifact( - transport: str = "grpc", request_type=metadata_service.CreateArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateArtifactRequest, dict,] +) +def test_create_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1645,10 +1638,6 @@ def test_create_artifact( assert response.description == "description_value" -def test_create_artifact_from_dict(): - test_create_artifact(request_type=dict) - - def test_create_artifact_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. @@ -1866,9 +1855,8 @@ async def test_create_artifact_flattened_error_async(): ) -def test_get_artifact( - transport: str = "grpc", request_type=metadata_service.GetArtifactRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetArtifactRequest, dict,]) +def test_get_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1909,10 +1897,6 @@ def test_get_artifact( assert response.description == "description_value" -def test_get_artifact_from_dict(): - test_get_artifact(request_type=dict) - - def test_get_artifact_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. @@ -2100,9 +2084,8 @@ async def test_get_artifact_flattened_error_async(): ) -def test_list_artifacts( - transport: str = "grpc", request_type=metadata_service.ListArtifactsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.ListArtifactsRequest, dict,]) +def test_list_artifacts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2129,10 +2112,6 @@ def test_list_artifacts( assert response.next_page_token == "next_page_token_value" -def test_list_artifacts_from_dict(): - test_list_artifacts(request_type=dict) - - def test_list_artifacts_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. @@ -2310,8 +2289,10 @@ async def test_list_artifacts_flattened_error_async(): ) -def test_list_artifacts_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_artifacts_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_artifacts), "__call__") as call: @@ -2350,8 +2331,10 @@ def test_list_artifacts_pager(): assert all(isinstance(i, artifact.Artifact) for i in results) -def test_list_artifacts_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_artifacts_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_artifacts), "__call__") as call: @@ -2460,9 +2443,10 @@ async def test_list_artifacts_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_artifact( - transport: str = "grpc", request_type=metadata_service.UpdateArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.UpdateArtifactRequest, dict,] +) +def test_update_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2503,10 +2487,6 @@ def test_update_artifact( assert response.description == "description_value" -def test_update_artifact_from_dict(): - test_update_artifact(request_type=dict) - - def test_update_artifact_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. @@ -2718,9 +2698,10 @@ async def test_update_artifact_flattened_error_async(): ) -def test_delete_artifact( - transport: str = "grpc", request_type=metadata_service.DeleteArtifactRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteArtifactRequest, dict,] +) +def test_delete_artifact(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2744,10 +2725,6 @@ def test_delete_artifact( assert isinstance(response, future.Future) -def test_delete_artifact_from_dict(): - test_delete_artifact(request_type=dict) - - def test_delete_artifact_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. @@ -2922,9 +2899,10 @@ async def test_delete_artifact_flattened_error_async(): ) -def test_purge_artifacts( - transport: str = "grpc", request_type=metadata_service.PurgeArtifactsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.PurgeArtifactsRequest, dict,] +) +def test_purge_artifacts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2948,10 +2926,6 @@ def test_purge_artifacts( assert isinstance(response, future.Future) -def test_purge_artifacts_from_dict(): - test_purge_artifacts(request_type=dict) - - def test_purge_artifacts_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. @@ -3126,9 +3100,8 @@ async def test_purge_artifacts_flattened_error_async(): ) -def test_create_context( - transport: str = "grpc", request_type=metadata_service.CreateContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.CreateContextRequest, dict,]) +def test_create_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3167,10 +3140,6 @@ def test_create_context( assert response.description == "description_value" -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. @@ -3382,9 +3351,8 @@ async def test_create_context_flattened_error_async(): ) -def test_get_context( - transport: str = "grpc", request_type=metadata_service.GetContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetContextRequest, dict,]) +def test_get_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3423,10 +3391,6 @@ def test_get_context( assert response.description == "description_value" -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. @@ -3612,9 +3576,8 @@ async def test_get_context_flattened_error_async(): ) -def test_list_contexts( - transport: str = "grpc", request_type=metadata_service.ListContextsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.ListContextsRequest, dict,]) +def test_list_contexts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3641,10 +3604,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. @@ -3822,8 +3781,10 @@ async def test_list_contexts_flattened_error_async(): ) -def test_list_contexts_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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: @@ -3856,8 +3817,10 @@ def test_list_contexts_pager(): assert all(isinstance(i, context.Context) for i in results) -def test_list_contexts_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_contexts_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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: @@ -3948,9 +3911,8 @@ async def test_list_contexts_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_context( - transport: str = "grpc", request_type=metadata_service.UpdateContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.UpdateContextRequest, dict,]) +def test_update_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3989,10 +3951,6 @@ def test_update_context( assert response.description == "description_value" -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. @@ -4198,9 +4156,8 @@ async def test_update_context_flattened_error_async(): ) -def test_delete_context( - transport: str = "grpc", request_type=metadata_service.DeleteContextRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.DeleteContextRequest, dict,]) +def test_delete_context(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4224,10 +4181,6 @@ def test_delete_context( assert isinstance(response, future.Future) -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. @@ -4402,9 +4355,8 @@ async def test_delete_context_flattened_error_async(): ) -def test_purge_contexts( - transport: str = "grpc", request_type=metadata_service.PurgeContextsRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.PurgeContextsRequest, dict,]) +def test_purge_contexts(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4428,10 +4380,6 @@ def test_purge_contexts( assert isinstance(response, future.Future) -def test_purge_contexts_from_dict(): - test_purge_contexts(request_type=dict) - - def test_purge_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. @@ -4606,10 +4554,10 @@ async def test_purge_contexts_flattened_error_async(): ) -def test_add_context_artifacts_and_executions( - transport: str = "grpc", - request_type=metadata_service.AddContextArtifactsAndExecutionsRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddContextArtifactsAndExecutionsRequest, dict,] +) +def test_add_context_artifacts_and_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4637,10 +4585,6 @@ def test_add_context_artifacts_and_executions( ) -def test_add_context_artifacts_and_executions_from_dict(): - test_add_context_artifacts_and_executions(request_type=dict) - - def test_add_context_artifacts_and_executions_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. @@ -4856,9 +4800,10 @@ async def test_add_context_artifacts_and_executions_flattened_error_async(): ) -def test_add_context_children( - transport: str = "grpc", request_type=metadata_service.AddContextChildrenRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddContextChildrenRequest, dict,] +) +def test_add_context_children(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4884,10 +4829,6 @@ def test_add_context_children( assert isinstance(response, metadata_service.AddContextChildrenResponse) -def test_add_context_children_from_dict(): - test_add_context_children(request_type=dict) - - def test_add_context_children_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. @@ -5089,10 +5030,10 @@ async def test_add_context_children_flattened_error_async(): ) -def test_query_context_lineage_subgraph( - transport: str = "grpc", - request_type=metadata_service.QueryContextLineageSubgraphRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryContextLineageSubgraphRequest, dict,] +) +def test_query_context_lineage_subgraph(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5118,10 +5059,6 @@ def test_query_context_lineage_subgraph( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_context_lineage_subgraph_from_dict(): - test_query_context_lineage_subgraph(request_type=dict) - - def test_query_context_lineage_subgraph_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. @@ -5311,9 +5248,10 @@ async def test_query_context_lineage_subgraph_flattened_error_async(): ) -def test_create_execution( - transport: str = "grpc", request_type=metadata_service.CreateExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateExecutionRequest, dict,] +) +def test_create_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5352,10 +5290,6 @@ def test_create_execution( assert response.description == "description_value" -def test_create_execution_from_dict(): - test_create_execution(request_type=dict) - - def test_create_execution_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. @@ -5572,9 +5506,8 @@ async def test_create_execution_flattened_error_async(): ) -def test_get_execution( - transport: str = "grpc", request_type=metadata_service.GetExecutionRequest -): +@pytest.mark.parametrize("request_type", [metadata_service.GetExecutionRequest, dict,]) +def test_get_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5613,10 +5546,6 @@ def test_get_execution( assert response.description == "description_value" -def test_get_execution_from_dict(): - test_get_execution(request_type=dict) - - def test_get_execution_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. @@ -5802,9 +5731,10 @@ async def test_get_execution_flattened_error_async(): ) -def test_list_executions( - transport: str = "grpc", request_type=metadata_service.ListExecutionsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListExecutionsRequest, dict,] +) +def test_list_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5831,10 +5761,6 @@ def test_list_executions( assert response.next_page_token == "next_page_token_value" -def test_list_executions_from_dict(): - test_list_executions(request_type=dict) - - def test_list_executions_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. @@ -6012,8 +5938,10 @@ async def test_list_executions_flattened_error_async(): ) -def test_list_executions_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_executions_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_executions), "__call__") as call: @@ -6052,8 +5980,10 @@ def test_list_executions_pager(): assert all(isinstance(i, execution.Execution) for i in results) -def test_list_executions_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_executions_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + 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_executions), "__call__") as call: @@ -6162,9 +6092,10 @@ async def test_list_executions_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_execution( - transport: str = "grpc", request_type=metadata_service.UpdateExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.UpdateExecutionRequest, dict,] +) +def test_update_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6203,10 +6134,6 @@ def test_update_execution( assert response.description == "description_value" -def test_update_execution_from_dict(): - test_update_execution(request_type=dict) - - def test_update_execution_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. @@ -6417,9 +6344,10 @@ async def test_update_execution_flattened_error_async(): ) -def test_delete_execution( - transport: str = "grpc", request_type=metadata_service.DeleteExecutionRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.DeleteExecutionRequest, dict,] +) +def test_delete_execution(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6443,10 +6371,6 @@ def test_delete_execution( assert isinstance(response, future.Future) -def test_delete_execution_from_dict(): - test_delete_execution(request_type=dict) - - def test_delete_execution_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. @@ -6622,9 +6546,10 @@ async def test_delete_execution_flattened_error_async(): ) -def test_purge_executions( - transport: str = "grpc", request_type=metadata_service.PurgeExecutionsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.PurgeExecutionsRequest, dict,] +) +def test_purge_executions(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6648,10 +6573,6 @@ def test_purge_executions( assert isinstance(response, future.Future) -def test_purge_executions_from_dict(): - test_purge_executions(request_type=dict) - - def test_purge_executions_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. @@ -6827,9 +6748,10 @@ async def test_purge_executions_flattened_error_async(): ) -def test_add_execution_events( - transport: str = "grpc", request_type=metadata_service.AddExecutionEventsRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.AddExecutionEventsRequest, dict,] +) +def test_add_execution_events(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6855,10 +6777,6 @@ def test_add_execution_events( assert isinstance(response, metadata_service.AddExecutionEventsResponse) -def test_add_execution_events_from_dict(): - test_add_execution_events(request_type=dict) - - def test_add_execution_events_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. @@ -7062,10 +6980,10 @@ async def test_add_execution_events_flattened_error_async(): ) -def test_query_execution_inputs_and_outputs( - transport: str = "grpc", - request_type=metadata_service.QueryExecutionInputsAndOutputsRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryExecutionInputsAndOutputsRequest, dict,] +) +def test_query_execution_inputs_and_outputs(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7091,10 +7009,6 @@ def test_query_execution_inputs_and_outputs( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_execution_inputs_and_outputs_from_dict(): - test_query_execution_inputs_and_outputs(request_type=dict) - - def test_query_execution_inputs_and_outputs_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. @@ -7286,9 +7200,10 @@ async def test_query_execution_inputs_and_outputs_flattened_error_async(): ) -def test_create_metadata_schema( - transport: str = "grpc", request_type=metadata_service.CreateMetadataSchemaRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.CreateMetadataSchemaRequest, dict,] +) +def test_create_metadata_schema(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7328,10 +7243,6 @@ def test_create_metadata_schema( assert response.description == "description_value" -def test_create_metadata_schema_from_dict(): - test_create_metadata_schema(request_type=dict) - - def test_create_metadata_schema_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. @@ -7559,9 +7470,10 @@ async def test_create_metadata_schema_flattened_error_async(): ) -def test_get_metadata_schema( - transport: str = "grpc", request_type=metadata_service.GetMetadataSchemaRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.GetMetadataSchemaRequest, dict,] +) +def test_get_metadata_schema(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7601,10 +7513,6 @@ def test_get_metadata_schema( assert response.description == "description_value" -def test_get_metadata_schema_from_dict(): - test_get_metadata_schema(request_type=dict) - - def test_get_metadata_schema_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. @@ -7806,9 +7714,10 @@ async def test_get_metadata_schema_flattened_error_async(): ) -def test_list_metadata_schemas( - transport: str = "grpc", request_type=metadata_service.ListMetadataSchemasRequest -): +@pytest.mark.parametrize( + "request_type", [metadata_service.ListMetadataSchemasRequest, dict,] +) +def test_list_metadata_schemas(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7837,10 +7746,6 @@ def test_list_metadata_schemas( assert response.next_page_token == "next_page_token_value" -def test_list_metadata_schemas_from_dict(): - test_list_metadata_schemas(request_type=dict) - - def test_list_metadata_schemas_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. @@ -8031,8 +7936,10 @@ async def test_list_metadata_schemas_flattened_error_async(): ) -def test_list_metadata_schemas_pager(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_schemas_pager(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8077,8 +7984,10 @@ def test_list_metadata_schemas_pager(): assert all(isinstance(i, metadata_schema.MetadataSchema) for i in results) -def test_list_metadata_schemas_pages(): - client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_metadata_schemas_pages(transport_name: str = "grpc"): + client = MetadataServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8205,10 +8114,10 @@ async def test_list_metadata_schemas_async_pages(): assert page_.raw_page.next_page_token == token -def test_query_artifact_lineage_subgraph( - transport: str = "grpc", - request_type=metadata_service.QueryArtifactLineageSubgraphRequest, -): +@pytest.mark.parametrize( + "request_type", [metadata_service.QueryArtifactLineageSubgraphRequest, dict,] +) +def test_query_artifact_lineage_subgraph(request_type, transport: str = "grpc"): client = MetadataServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -8234,10 +8143,6 @@ def test_query_artifact_lineage_subgraph( assert isinstance(response, lineage_subgraph.LineageSubgraph) -def test_query_artifact_lineage_subgraph_from_dict(): - test_query_artifact_lineage_subgraph(request_type=dict) - - def test_query_artifact_lineage_subgraph_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. @@ -9130,7 +9035,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/aiplatform_v1beta1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py index 176dc81e61..8b85c1430c 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py @@ -256,20 +256,20 @@ def test_migration_service_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_migration_service_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_migration_service_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_migration_service_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_migration_service_client_client_options_from_dict(): ) -def test_search_migratable_resources( - transport: str = "grpc", - request_type=migration_service.SearchMigratableResourcesRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.SearchMigratableResourcesRequest, dict,] +) +def test_search_migratable_resources(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -529,10 +529,6 @@ def test_search_migratable_resources( assert response.next_page_token == "next_page_token_value" -def test_search_migratable_resources_from_dict(): - test_search_migratable_resources(request_type=dict) - - def test_search_migratable_resources_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. @@ -723,8 +719,10 @@ async def test_search_migratable_resources_flattened_error_async(): ) -def test_search_migratable_resources_pager(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_migratable_resources_pager(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -771,8 +769,10 @@ def test_search_migratable_resources_pager(): ) -def test_search_migratable_resources_pages(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_search_migratable_resources_pages(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -901,9 +901,10 @@ async def test_search_migratable_resources_async_pages(): assert page_.raw_page.next_page_token == token -def test_batch_migrate_resources( - transport: str = "grpc", request_type=migration_service.BatchMigrateResourcesRequest -): +@pytest.mark.parametrize( + "request_type", [migration_service.BatchMigrateResourcesRequest, dict,] +) +def test_batch_migrate_resources(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -929,10 +930,6 @@ def test_batch_migrate_resources( assert isinstance(response, future.Future) -def test_batch_migrate_resources_from_dict(): - test_batch_migrate_resources(request_type=dict) - - def test_batch_migrate_resources_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. @@ -1626,20 +1623,18 @@ def test_parse_annotated_dataset_path(): def test_dataset_path(): project = "cuttlefish" - location = "mussel" - dataset = "winkle" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( - project=project, location=location, dataset=dataset, + dataset = "mussel" + expected = "projects/{project}/datasets/{dataset}".format( + project=project, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, location, dataset) + actual = MigrationServiceClient.dataset_path(project, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "nautilus", - "location": "scallop", - "dataset": "abalone", + "project": "winkle", + "dataset": "nautilus", } path = MigrationServiceClient.dataset_path(**expected) @@ -1649,18 +1644,20 @@ def test_parse_dataset_path(): def test_dataset_path(): - project = "squid" - dataset = "clam" - expected = "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, + project = "scallop" + location = "abalone" + dataset = "squid" + expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( + project=project, location=location, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, dataset) + actual = MigrationServiceClient.dataset_path(project, location, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "whelk", + "project": "clam", + "location": "whelk", "dataset": "octopus", } path = MigrationServiceClient.dataset_path(**expected) @@ -1862,7 +1859,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/aiplatform_v1beta1/test_model_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py index 31bb04d225..b98803d320 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py @@ -257,20 +257,20 @@ def test_model_service_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, @@ -327,7 +327,7 @@ def test_model_service_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 @@ -422,7 +422,7 @@ def test_model_service_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, @@ -453,7 +453,7 @@ def test_model_service_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,8 @@ def test_model_service_client_client_options_from_dict(): ) -def test_upload_model( - transport: str = "grpc", request_type=model_service.UploadModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.UploadModelRequest, dict,]) +def test_upload_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -510,10 +509,6 @@ def test_upload_model( assert isinstance(response, future.Future) -def test_upload_model_from_dict(): - test_upload_model(request_type=dict) - - def test_upload_model_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. @@ -696,7 +691,8 @@ async def test_upload_model_flattened_error_async(): ) -def test_get_model(transport: str = "grpc", request_type=model_service.GetModelRequest): +@pytest.mark.parametrize("request_type", [model_service.GetModelRequest, dict,]) +def test_get_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -749,10 +745,6 @@ def test_get_model(transport: str = "grpc", request_type=model_service.GetModelR assert response.etag == "etag_value" -def test_get_model_from_dict(): - test_get_model(request_type=dict) - - def test_get_model_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. @@ -950,9 +942,8 @@ async def test_get_model_flattened_error_async(): ) -def test_list_models( - transport: str = "grpc", request_type=model_service.ListModelsRequest -): +@pytest.mark.parametrize("request_type", [model_service.ListModelsRequest, dict,]) +def test_list_models(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -979,10 +970,6 @@ def test_list_models( assert response.next_page_token == "next_page_token_value" -def test_list_models_from_dict(): - test_list_models(request_type=dict) - - def test_list_models_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. @@ -1152,8 +1139,10 @@ async def test_list_models_flattened_error_async(): ) -def test_list_models_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_models_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + 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_models), "__call__") as call: @@ -1184,8 +1173,10 @@ def test_list_models_pager(): assert all(isinstance(i, model.Model) for i in results) -def test_list_models_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_models_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + 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_models), "__call__") as call: @@ -1266,9 +1257,8 @@ async def test_list_models_async_pages(): assert page_.raw_page.next_page_token == token -def test_update_model( - transport: str = "grpc", request_type=model_service.UpdateModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.UpdateModelRequest, dict,]) +def test_update_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1321,10 +1311,6 @@ def test_update_model( assert response.etag == "etag_value" -def test_update_model_from_dict(): - test_update_model(request_type=dict) - - def test_update_model_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. @@ -1538,9 +1524,8 @@ async def test_update_model_flattened_error_async(): ) -def test_delete_model( - transport: str = "grpc", request_type=model_service.DeleteModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.DeleteModelRequest, dict,]) +def test_delete_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1564,10 +1549,6 @@ def test_delete_model( assert isinstance(response, future.Future) -def test_delete_model_from_dict(): - test_delete_model(request_type=dict) - - def test_delete_model_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. @@ -1736,9 +1717,8 @@ async def test_delete_model_flattened_error_async(): ) -def test_export_model( - transport: str = "grpc", request_type=model_service.ExportModelRequest -): +@pytest.mark.parametrize("request_type", [model_service.ExportModelRequest, dict,]) +def test_export_model(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1762,10 +1742,6 @@ def test_export_model( assert isinstance(response, future.Future) -def test_export_model_from_dict(): - test_export_model(request_type=dict) - - def test_export_model_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. @@ -1962,9 +1938,10 @@ async def test_export_model_flattened_error_async(): ) -def test_get_model_evaluation( - transport: str = "grpc", request_type=model_service.GetModelEvaluationRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.GetModelEvaluationRequest, dict,] +) +def test_get_model_evaluation(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1997,10 +1974,6 @@ def test_get_model_evaluation( assert response.slice_dimensions == ["slice_dimensions_value"] -def test_get_model_evaluation_from_dict(): - test_get_model_evaluation(request_type=dict) - - def test_get_model_evaluation_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. @@ -2189,9 +2162,10 @@ async def test_get_model_evaluation_flattened_error_async(): ) -def test_list_model_evaluations( - transport: str = "grpc", request_type=model_service.ListModelEvaluationsRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.ListModelEvaluationsRequest, dict,] +) +def test_list_model_evaluations(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2220,10 +2194,6 @@ def test_list_model_evaluations( assert response.next_page_token == "next_page_token_value" -def test_list_model_evaluations_from_dict(): - test_list_model_evaluations(request_type=dict) - - def test_list_model_evaluations_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. @@ -2408,8 +2378,10 @@ async def test_list_model_evaluations_flattened_error_async(): ) -def test_list_model_evaluations_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluations_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2454,8 +2426,10 @@ def test_list_model_evaluations_pager(): assert all(isinstance(i, model_evaluation.ModelEvaluation) for i in results) -def test_list_model_evaluations_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluations_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2578,9 +2552,10 @@ async def test_list_model_evaluations_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_model_evaluation_slice( - transport: str = "grpc", request_type=model_service.GetModelEvaluationSliceRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.GetModelEvaluationSliceRequest, dict,] +) +def test_get_model_evaluation_slice(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2610,10 +2585,6 @@ def test_get_model_evaluation_slice( assert response.metrics_schema_uri == "metrics_schema_uri_value" -def test_get_model_evaluation_slice_from_dict(): - test_get_model_evaluation_slice(request_type=dict) - - def test_get_model_evaluation_slice_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. @@ -2799,9 +2770,10 @@ async def test_get_model_evaluation_slice_flattened_error_async(): ) -def test_list_model_evaluation_slices( - transport: str = "grpc", request_type=model_service.ListModelEvaluationSlicesRequest -): +@pytest.mark.parametrize( + "request_type", [model_service.ListModelEvaluationSlicesRequest, dict,] +) +def test_list_model_evaluation_slices(request_type, transport: str = "grpc"): client = ModelServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2830,10 +2802,6 @@ def test_list_model_evaluation_slices( assert response.next_page_token == "next_page_token_value" -def test_list_model_evaluation_slices_from_dict(): - test_list_model_evaluation_slices(request_type=dict) - - def test_list_model_evaluation_slices_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. @@ -3018,8 +2986,10 @@ async def test_list_model_evaluation_slices_flattened_error_async(): ) -def test_list_model_evaluation_slices_pager(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluation_slices_pager(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3068,8 +3038,10 @@ def test_list_model_evaluation_slices_pager(): ) -def test_list_model_evaluation_slices_pages(): - client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_model_evaluation_slices_pages(transport_name: str = "grpc"): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3858,7 +3830,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/aiplatform_v1beta1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py index 2f587a9d04..5cd5337038 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py @@ -278,20 +278,20 @@ def test_pipeline_service_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, @@ -360,7 +360,7 @@ def test_pipeline_service_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 @@ -455,7 +455,7 @@ def test_pipeline_service_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, @@ -486,7 +486,7 @@ def test_pipeline_service_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", @@ -519,9 +519,10 @@ def test_pipeline_service_client_client_options_from_dict(): ) -def test_create_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.CreateTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CreateTrainingPipelineRequest, dict,] +) +def test_create_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -556,10 +557,6 @@ def test_create_training_pipeline( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED -def test_create_training_pipeline_from_dict(): - test_create_training_pipeline(request_type=dict) - - def test_create_training_pipeline_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. @@ -772,9 +769,10 @@ async def test_create_training_pipeline_flattened_error_async(): ) -def test_get_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.GetTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.GetTrainingPipelineRequest, dict,] +) +def test_get_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -809,10 +807,6 @@ def test_get_training_pipeline( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED -def test_get_training_pipeline_from_dict(): - test_get_training_pipeline(request_type=dict) - - def test_get_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1009,9 +1003,10 @@ async def test_get_training_pipeline_flattened_error_async(): ) -def test_list_training_pipelines( - transport: str = "grpc", request_type=pipeline_service.ListTrainingPipelinesRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.ListTrainingPipelinesRequest, dict,] +) +def test_list_training_pipelines(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1040,10 +1035,6 @@ def test_list_training_pipelines( assert response.next_page_token == "next_page_token_value" -def test_list_training_pipelines_from_dict(): - test_list_training_pipelines(request_type=dict) - - def test_list_training_pipelines_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. @@ -1234,8 +1225,10 @@ async def test_list_training_pipelines_flattened_error_async(): ) -def test_list_training_pipelines_pager(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_training_pipelines_pager(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1280,8 +1273,10 @@ def test_list_training_pipelines_pager(): assert all(isinstance(i, training_pipeline.TrainingPipeline) for i in results) -def test_list_training_pipelines_pages(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_training_pipelines_pages(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1408,9 +1403,10 @@ async def test_list_training_pipelines_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.DeleteTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.DeleteTrainingPipelineRequest, dict,] +) +def test_delete_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1436,10 +1432,6 @@ def test_delete_training_pipeline( assert isinstance(response, future.Future) -def test_delete_training_pipeline_from_dict(): - test_delete_training_pipeline(request_type=dict) - - def test_delete_training_pipeline_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. @@ -1627,9 +1619,10 @@ async def test_delete_training_pipeline_flattened_error_async(): ) -def test_cancel_training_pipeline( - transport: str = "grpc", request_type=pipeline_service.CancelTrainingPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CancelTrainingPipelineRequest, dict,] +) +def test_cancel_training_pipeline(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1655,10 +1648,6 @@ def test_cancel_training_pipeline( assert response is None -def test_cancel_training_pipeline_from_dict(): - test_cancel_training_pipeline(request_type=dict) - - def test_cancel_training_pipeline_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. @@ -1840,9 +1829,10 @@ async def test_cancel_training_pipeline_flattened_error_async(): ) -def test_create_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.CreatePipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CreatePipelineJobRequest, dict,] +) +def test_create_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1879,10 +1869,6 @@ def test_create_pipeline_job( assert response.network == "network_value" -def test_create_pipeline_job_from_dict(): - test_create_pipeline_job(request_type=dict) - - def test_create_pipeline_job_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. @@ -2107,9 +2093,10 @@ async def test_create_pipeline_job_flattened_error_async(): ) -def test_get_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.GetPipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.GetPipelineJobRequest, dict,] +) +def test_get_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2144,10 +2131,6 @@ def test_get_pipeline_job( assert response.network == "network_value" -def test_get_pipeline_job_from_dict(): - test_get_pipeline_job(request_type=dict) - - def test_get_pipeline_job_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. @@ -2333,9 +2316,10 @@ async def test_get_pipeline_job_flattened_error_async(): ) -def test_list_pipeline_jobs( - transport: str = "grpc", request_type=pipeline_service.ListPipelineJobsRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.ListPipelineJobsRequest, dict,] +) +def test_list_pipeline_jobs(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2364,10 +2348,6 @@ def test_list_pipeline_jobs( assert response.next_page_token == "next_page_token_value" -def test_list_pipeline_jobs_from_dict(): - test_list_pipeline_jobs(request_type=dict) - - def test_list_pipeline_jobs_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. @@ -2558,8 +2538,10 @@ async def test_list_pipeline_jobs_flattened_error_async(): ) -def test_list_pipeline_jobs_pager(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_pipeline_jobs_pager(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2600,8 +2582,10 @@ def test_list_pipeline_jobs_pager(): assert all(isinstance(i, pipeline_job.PipelineJob) for i in results) -def test_list_pipeline_jobs_pages(): - client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_pipeline_jobs_pages(transport_name: str = "grpc"): + client = PipelineServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2716,9 +2700,10 @@ async def test_list_pipeline_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.DeletePipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.DeletePipelineJobRequest, dict,] +) +def test_delete_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2744,10 +2729,6 @@ def test_delete_pipeline_job( assert isinstance(response, future.Future) -def test_delete_pipeline_job_from_dict(): - test_delete_pipeline_job(request_type=dict) - - def test_delete_pipeline_job_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. @@ -2935,9 +2916,10 @@ async def test_delete_pipeline_job_flattened_error_async(): ) -def test_cancel_pipeline_job( - transport: str = "grpc", request_type=pipeline_service.CancelPipelineJobRequest -): +@pytest.mark.parametrize( + "request_type", [pipeline_service.CancelPipelineJobRequest, dict,] +) +def test_cancel_pipeline_job(request_type, transport: str = "grpc"): client = PipelineServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2963,10 +2945,6 @@ def test_cancel_pipeline_job( assert response is None -def test_cancel_pipeline_job_from_dict(): - test_cancel_pipeline_job(request_type=dict) - - def test_cancel_pipeline_job_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. @@ -3915,7 +3893,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/aiplatform_v1beta1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py index aa0f4c76b5..e7e9ac42c0 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py @@ -255,20 +255,20 @@ def test_prediction_service_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, @@ -337,7 +337,7 @@ def test_prediction_service_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 @@ -432,7 +432,7 @@ def test_prediction_service_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, @@ -463,7 +463,7 @@ def test_prediction_service_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", @@ -496,9 +496,8 @@ def test_prediction_service_client_client_options_from_dict(): ) -def test_predict( - transport: str = "grpc", request_type=prediction_service.PredictRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,]) +def test_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -529,10 +528,6 @@ def test_predict( assert response.model_display_name == "model_display_name_value" -def test_predict_from_dict(): - test_predict(request_type=dict) - - def test_predict_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. @@ -673,9 +668,8 @@ async def test_predict_flattened_error_async(): ) -def test_raw_predict( - transport: str = "grpc", request_type=prediction_service.RawPredictRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.RawPredictRequest, dict,]) +def test_raw_predict(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -703,10 +697,6 @@ def test_raw_predict( assert response.data == b"data_blob" -def test_raw_predict_from_dict(): - test_raw_predict(request_type=dict) - - def test_raw_predict_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. @@ -899,9 +889,8 @@ async def test_raw_predict_flattened_error_async(): ) -def test_explain( - transport: str = "grpc", request_type=prediction_service.ExplainRequest -): +@pytest.mark.parametrize("request_type", [prediction_service.ExplainRequest, dict,]) +def test_explain(request_type, transport: str = "grpc"): client = PredictionServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -928,10 +917,6 @@ def test_explain( assert response.deployed_model_id == "deployed_model_id_value" -def test_explain_from_dict(): - test_explain(request_type=dict) - - def test_explain_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. @@ -1610,7 +1595,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/aiplatform_v1beta1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py index 490e6d5f97..f32c4ee117 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py @@ -263,20 +263,20 @@ def test_specialist_pool_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -345,7 +345,7 @@ def test_specialist_pool_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -444,7 +444,7 @@ def test_specialist_pool_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -479,7 +479,7 @@ def test_specialist_pool_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -512,10 +512,10 @@ def test_specialist_pool_service_client_client_options_from_dict(): ) -def test_create_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.CreateSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.CreateSpecialistPoolRequest, dict,] +) +def test_create_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -541,10 +541,6 @@ def test_create_specialist_pool( assert isinstance(response, future.Future) -def test_create_specialist_pool_from_dict(): - test_create_specialist_pool(request_type=dict) - - def test_create_specialist_pool_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. @@ -754,10 +750,10 @@ async def test_create_specialist_pool_flattened_error_async(): ) -def test_get_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.GetSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.GetSpecialistPoolRequest, dict,] +) +def test_get_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -796,10 +792,6 @@ def test_get_specialist_pool( assert response.specialist_worker_emails == ["specialist_worker_emails_value"] -def test_get_specialist_pool_from_dict(): - test_get_specialist_pool(request_type=dict) - - def test_get_specialist_pool_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. @@ -1006,10 +998,10 @@ async def test_get_specialist_pool_flattened_error_async(): ) -def test_list_specialist_pools( - transport: str = "grpc", - request_type=specialist_pool_service.ListSpecialistPoolsRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.ListSpecialistPoolsRequest, dict,] +) +def test_list_specialist_pools(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1038,10 +1030,6 @@ def test_list_specialist_pools( assert response.next_page_token == "next_page_token_value" -def test_list_specialist_pools_from_dict(): - test_list_specialist_pools(request_type=dict) - - def test_list_specialist_pools_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1238,9 +1226,9 @@ async def test_list_specialist_pools_flattened_error_async(): ) -def test_list_specialist_pools_pager(): +def test_list_specialist_pools_pager(transport_name: str = "grpc"): client = SpecialistPoolServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1286,9 +1274,9 @@ def test_list_specialist_pools_pager(): assert all(isinstance(i, specialist_pool.SpecialistPool) for i in results) -def test_list_specialist_pools_pages(): +def test_list_specialist_pools_pages(transport_name: str = "grpc"): client = SpecialistPoolServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1416,10 +1404,10 @@ async def test_list_specialist_pools_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.DeleteSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.DeleteSpecialistPoolRequest, dict,] +) +def test_delete_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1445,10 +1433,6 @@ def test_delete_specialist_pool( assert isinstance(response, future.Future) -def test_delete_specialist_pool_from_dict(): - test_delete_specialist_pool(request_type=dict) - - def test_delete_specialist_pool_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,10 +1626,10 @@ async def test_delete_specialist_pool_flattened_error_async(): ) -def test_update_specialist_pool( - transport: str = "grpc", - request_type=specialist_pool_service.UpdateSpecialistPoolRequest, -): +@pytest.mark.parametrize( + "request_type", [specialist_pool_service.UpdateSpecialistPoolRequest, dict,] +) +def test_update_specialist_pool(request_type, transport: str = "grpc"): client = SpecialistPoolServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1671,10 +1655,6 @@ def test_update_specialist_pool( assert isinstance(response, future.Future) -def test_update_specialist_pool_from_dict(): - test_update_specialist_pool(request_type=dict) - - def test_update_specialist_pool_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,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/aiplatform_v1beta1/test_tensorboard_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py index 332bf28c9a..6658e8b922 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py @@ -272,20 +272,20 @@ def test_tensorboard_service_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, @@ -354,7 +354,7 @@ def test_tensorboard_service_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 @@ -449,7 +449,7 @@ def test_tensorboard_service_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, @@ -480,7 +480,7 @@ def test_tensorboard_service_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", @@ -513,9 +513,10 @@ def test_tensorboard_service_client_client_options_from_dict(): ) -def test_create_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.CreateTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardRequest, dict,] +) +def test_create_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -541,10 +542,6 @@ def test_create_tensorboard( assert isinstance(response, future.Future) -def test_create_tensorboard_from_dict(): - test_create_tensorboard(request_type=dict) - - def test_create_tensorboard_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. @@ -754,9 +751,10 @@ async def test_create_tensorboard_flattened_error_async(): ) -def test_get_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardRequest, dict,] +) +def test_get_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -793,10 +791,6 @@ def test_get_tensorboard( assert response.etag == "etag_value" -def test_get_tensorboard_from_dict(): - test_get_tensorboard(request_type=dict) - - def test_get_tensorboard_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. @@ -991,9 +985,10 @@ async def test_get_tensorboard_flattened_error_async(): ) -def test_update_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.UpdateTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardRequest, dict,] +) +def test_update_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1019,10 +1014,6 @@ def test_update_tensorboard( assert isinstance(response, future.Future) -def test_update_tensorboard_from_dict(): - test_update_tensorboard(request_type=dict) - - def test_update_tensorboard_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. @@ -1236,9 +1227,10 @@ async def test_update_tensorboard_flattened_error_async(): ) -def test_list_tensorboards( - transport: str = "grpc", request_type=tensorboard_service.ListTensorboardsRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardsRequest, dict,] +) +def test_list_tensorboards(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1267,10 +1259,6 @@ def test_list_tensorboards( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboards_from_dict(): - test_list_tensorboards(request_type=dict) - - def test_list_tensorboards_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. @@ -1467,8 +1455,10 @@ async def test_list_tensorboards_flattened_error_async(): ) -def test_list_tensorboards_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboards_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1509,8 +1499,10 @@ def test_list_tensorboards_pager(): assert all(isinstance(i, tensorboard.Tensorboard) for i in results) -def test_list_tensorboards_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboards_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1625,9 +1617,10 @@ async def test_list_tensorboards_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard( - transport: str = "grpc", request_type=tensorboard_service.DeleteTensorboardRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardRequest, dict,] +) +def test_delete_tensorboard(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1653,10 +1646,6 @@ def test_delete_tensorboard( assert isinstance(response, future.Future) -def test_delete_tensorboard_from_dict(): - test_delete_tensorboard(request_type=dict) - - def test_delete_tensorboard_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. @@ -1850,10 +1839,10 @@ async def test_delete_tensorboard_flattened_error_async(): ) -def test_create_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardExperimentRequest, dict,] +) +def test_create_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1890,10 +1879,6 @@ def test_create_tensorboard_experiment( assert response.source == "source_value" -def test_create_tensorboard_experiment_from_dict(): - test_create_tensorboard_experiment(request_type=dict) - - def test_create_tensorboard_experiment_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. @@ -2132,10 +2117,10 @@ async def test_create_tensorboard_experiment_flattened_error_async(): ) -def test_get_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.GetTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardExperimentRequest, dict,] +) +def test_get_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2172,10 +2157,6 @@ def test_get_tensorboard_experiment( assert response.source == "source_value" -def test_get_tensorboard_experiment_from_dict(): - test_get_tensorboard_experiment(request_type=dict) - - def test_get_tensorboard_experiment_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. @@ -2380,10 +2361,10 @@ async def test_get_tensorboard_experiment_flattened_error_async(): ) -def test_update_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardExperimentRequest, dict,] +) +def test_update_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2420,10 +2401,6 @@ def test_update_tensorboard_experiment( assert response.source == "source_value" -def test_update_tensorboard_experiment_from_dict(): - test_update_tensorboard_experiment(request_type=dict) - - def test_update_tensorboard_experiment_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. @@ -2658,10 +2635,10 @@ async def test_update_tensorboard_experiment_flattened_error_async(): ) -def test_list_tensorboard_experiments( - transport: str = "grpc", - request_type=tensorboard_service.ListTensorboardExperimentsRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardExperimentsRequest, dict,] +) +def test_list_tensorboard_experiments(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2690,10 +2667,6 @@ def test_list_tensorboard_experiments( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_experiments_from_dict(): - test_list_tensorboard_experiments(request_type=dict) - - def test_list_tensorboard_experiments_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. @@ -2892,8 +2865,10 @@ async def test_list_tensorboard_experiments_flattened_error_async(): ) -def test_list_tensorboard_experiments_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_experiments_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2942,8 +2917,10 @@ def test_list_tensorboard_experiments_pager(): ) -def test_list_tensorboard_experiments_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_experiments_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3081,10 +3058,10 @@ async def test_list_tensorboard_experiments_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_experiment( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardExperimentRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardExperimentRequest, dict,] +) +def test_delete_tensorboard_experiment(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3110,10 +3087,6 @@ def test_delete_tensorboard_experiment( assert isinstance(response, future.Future) -def test_delete_tensorboard_experiment_from_dict(): - test_delete_tensorboard_experiment(request_type=dict) - - def test_delete_tensorboard_experiment_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. @@ -3307,10 +3280,10 @@ async def test_delete_tensorboard_experiment_flattened_error_async(): ) -def test_create_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardRunRequest, dict,] +) +def test_create_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3345,10 +3318,6 @@ def test_create_tensorboard_run( assert response.etag == "etag_value" -def test_create_tensorboard_run_from_dict(): - test_create_tensorboard_run(request_type=dict) - - def test_create_tensorboard_run_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. @@ -3577,10 +3546,10 @@ async def test_create_tensorboard_run_flattened_error_async(): ) -def test_batch_create_tensorboard_runs( - transport: str = "grpc", - request_type=tensorboard_service.BatchCreateTensorboardRunsRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.BatchCreateTensorboardRunsRequest, dict,] +) +def test_batch_create_tensorboard_runs(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3606,10 +3575,6 @@ def test_batch_create_tensorboard_runs( assert isinstance(response, tensorboard_service.BatchCreateTensorboardRunsResponse) -def test_batch_create_tensorboard_runs_from_dict(): - test_batch_create_tensorboard_runs(request_type=dict) - - def test_batch_create_tensorboard_runs_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. @@ -3831,9 +3796,10 @@ async def test_batch_create_tensorboard_runs_flattened_error_async(): ) -def test_get_tensorboard_run( - transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRunRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardRunRequest, dict,] +) +def test_get_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3868,10 +3834,6 @@ def test_get_tensorboard_run( assert response.etag == "etag_value" -def test_get_tensorboard_run_from_dict(): - test_get_tensorboard_run(request_type=dict) - - def test_get_tensorboard_run_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. @@ -4074,10 +4036,10 @@ async def test_get_tensorboard_run_flattened_error_async(): ) -def test_update_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardRunRequest, dict,] +) +def test_update_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4112,10 +4074,6 @@ def test_update_tensorboard_run( assert response.etag == "etag_value" -def test_update_tensorboard_run_from_dict(): - test_update_tensorboard_run(request_type=dict) - - def test_update_tensorboard_run_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. @@ -4340,9 +4298,10 @@ async def test_update_tensorboard_run_flattened_error_async(): ) -def test_list_tensorboard_runs( - transport: str = "grpc", request_type=tensorboard_service.ListTensorboardRunsRequest -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardRunsRequest, dict,] +) +def test_list_tensorboard_runs(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4371,10 +4330,6 @@ def test_list_tensorboard_runs( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_runs_from_dict(): - test_list_tensorboard_runs(request_type=dict) - - def test_list_tensorboard_runs_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. @@ -4571,8 +4526,10 @@ async def test_list_tensorboard_runs_flattened_error_async(): ) -def test_list_tensorboard_runs_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_runs_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4617,8 +4574,10 @@ def test_list_tensorboard_runs_pager(): assert all(isinstance(i, tensorboard_run.TensorboardRun) for i in results) -def test_list_tensorboard_runs_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_runs_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4745,10 +4704,10 @@ async def test_list_tensorboard_runs_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_run( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardRunRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardRunRequest, dict,] +) +def test_delete_tensorboard_run(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4774,10 +4733,6 @@ def test_delete_tensorboard_run( assert isinstance(response, future.Future) -def test_delete_tensorboard_run_from_dict(): - test_delete_tensorboard_run(request_type=dict) - - def test_delete_tensorboard_run_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. @@ -4971,10 +4926,10 @@ async def test_delete_tensorboard_run_flattened_error_async(): ) -def test_batch_create_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.BatchCreateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.BatchCreateTensorboardTimeSeriesRequest, dict,] +) +def test_batch_create_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5004,10 +4959,6 @@ def test_batch_create_tensorboard_time_series( ) -def test_batch_create_tensorboard_time_series_from_dict(): - test_batch_create_tensorboard_time_series(request_type=dict) - - def test_batch_create_tensorboard_time_series_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. @@ -5249,10 +5200,10 @@ async def test_batch_create_tensorboard_time_series_flattened_error_async(): ) -def test_create_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.CreateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.CreateTensorboardTimeSeriesRequest, dict,] +) +def test_create_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5296,10 +5247,6 @@ def test_create_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_create_tensorboard_time_series_from_dict(): - test_create_tensorboard_time_series(request_type=dict) - - def test_create_tensorboard_time_series_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. @@ -5535,10 +5482,10 @@ async def test_create_tensorboard_time_series_flattened_error_async(): ) -def test_get_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.GetTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.GetTensorboardTimeSeriesRequest, dict,] +) +def test_get_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5582,10 +5529,6 @@ def test_get_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_get_tensorboard_time_series_from_dict(): - test_get_tensorboard_time_series(request_type=dict) - - def test_get_tensorboard_time_series_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. @@ -5797,10 +5740,10 @@ async def test_get_tensorboard_time_series_flattened_error_async(): ) -def test_update_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.UpdateTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.UpdateTensorboardTimeSeriesRequest, dict,] +) +def test_update_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -5844,10 +5787,6 @@ def test_update_tensorboard_time_series( assert response.plugin_data == b"plugin_data_blob" -def test_update_tensorboard_time_series_from_dict(): - test_update_tensorboard_time_series(request_type=dict) - - def test_update_tensorboard_time_series_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. @@ -6089,10 +6028,10 @@ async def test_update_tensorboard_time_series_flattened_error_async(): ) -def test_list_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.ListTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ListTensorboardTimeSeriesRequest, dict,] +) +def test_list_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6121,10 +6060,6 @@ def test_list_tensorboard_time_series( assert response.next_page_token == "next_page_token_value" -def test_list_tensorboard_time_series_from_dict(): - test_list_tensorboard_time_series(request_type=dict) - - def test_list_tensorboard_time_series_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. @@ -6323,8 +6258,10 @@ async def test_list_tensorboard_time_series_flattened_error_async(): ) -def test_list_tensorboard_time_series_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_time_series_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6374,8 +6311,10 @@ def test_list_tensorboard_time_series_pager(): ) -def test_list_tensorboard_time_series_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tensorboard_time_series_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6513,10 +6452,10 @@ async def test_list_tensorboard_time_series_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_tensorboard_time_series( - transport: str = "grpc", - request_type=tensorboard_service.DeleteTensorboardTimeSeriesRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.DeleteTensorboardTimeSeriesRequest, dict,] +) +def test_delete_tensorboard_time_series(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6542,10 +6481,6 @@ def test_delete_tensorboard_time_series( assert isinstance(response, future.Future) -def test_delete_tensorboard_time_series_from_dict(): - test_delete_tensorboard_time_series(request_type=dict) - - def test_delete_tensorboard_time_series_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. @@ -6739,10 +6674,11 @@ async def test_delete_tensorboard_time_series_flattened_error_async(): ) -def test_batch_read_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.BatchReadTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", + [tensorboard_service.BatchReadTensorboardTimeSeriesDataRequest, dict,], +) +def test_batch_read_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -6774,10 +6710,6 @@ def test_batch_read_tensorboard_time_series_data( ) -def test_batch_read_tensorboard_time_series_data_from_dict(): - test_batch_read_tensorboard_time_series_data(request_type=dict) - - def test_batch_read_tensorboard_time_series_data_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. @@ -6987,10 +6919,10 @@ async def test_batch_read_tensorboard_time_series_data_flattened_error_async(): ) -def test_read_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.ReadTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ReadTensorboardTimeSeriesDataRequest, dict,] +) +def test_read_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7018,10 +6950,6 @@ def test_read_tensorboard_time_series_data( ) -def test_read_tensorboard_time_series_data_from_dict(): - test_read_tensorboard_time_series_data(request_type=dict) - - def test_read_tensorboard_time_series_data_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. @@ -7229,10 +7157,10 @@ async def test_read_tensorboard_time_series_data_flattened_error_async(): ) -def test_read_tensorboard_blob_data( - transport: str = "grpc", - request_type=tensorboard_service.ReadTensorboardBlobDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ReadTensorboardBlobDataRequest, dict,] +) +def test_read_tensorboard_blob_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7261,10 +7189,6 @@ def test_read_tensorboard_blob_data( assert isinstance(message, tensorboard_service.ReadTensorboardBlobDataResponse) -def test_read_tensorboard_blob_data_from_dict(): - test_read_tensorboard_blob_data(request_type=dict) - - def test_read_tensorboard_blob_data_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. @@ -7469,10 +7393,10 @@ async def test_read_tensorboard_blob_data_flattened_error_async(): ) -def test_write_tensorboard_experiment_data( - transport: str = "grpc", - request_type=tensorboard_service.WriteTensorboardExperimentDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.WriteTensorboardExperimentDataRequest, dict,] +) +def test_write_tensorboard_experiment_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7500,10 +7424,6 @@ def test_write_tensorboard_experiment_data( ) -def test_write_tensorboard_experiment_data_from_dict(): - test_write_tensorboard_experiment_data(request_type=dict) - - def test_write_tensorboard_experiment_data_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. @@ -7745,10 +7665,10 @@ async def test_write_tensorboard_experiment_data_flattened_error_async(): ) -def test_write_tensorboard_run_data( - transport: str = "grpc", - request_type=tensorboard_service.WriteTensorboardRunDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.WriteTensorboardRunDataRequest, dict,] +) +def test_write_tensorboard_run_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -7774,10 +7694,6 @@ def test_write_tensorboard_run_data( assert isinstance(response, tensorboard_service.WriteTensorboardRunDataResponse) -def test_write_tensorboard_run_data_from_dict(): - test_write_tensorboard_run_data(request_type=dict) - - def test_write_tensorboard_run_data_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. @@ -8015,10 +7931,10 @@ async def test_write_tensorboard_run_data_flattened_error_async(): ) -def test_export_tensorboard_time_series_data( - transport: str = "grpc", - request_type=tensorboard_service.ExportTensorboardTimeSeriesDataRequest, -): +@pytest.mark.parametrize( + "request_type", [tensorboard_service.ExportTensorboardTimeSeriesDataRequest, dict,] +) +def test_export_tensorboard_time_series_data(request_type, transport: str = "grpc"): client = TensorboardServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -8047,10 +7963,6 @@ def test_export_tensorboard_time_series_data( assert response.next_page_token == "next_page_token_value" -def test_export_tensorboard_time_series_data_from_dict(): - test_export_tensorboard_time_series_data(request_type=dict) - - def test_export_tensorboard_time_series_data_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. @@ -8265,8 +8177,10 @@ async def test_export_tensorboard_time_series_data_flattened_error_async(): ) -def test_export_tensorboard_time_series_data_pager(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_export_tensorboard_time_series_data_pager(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8313,8 +8227,10 @@ def test_export_tensorboard_time_series_data_pager(): assert all(isinstance(i, tensorboard_data.TimeSeriesDataPoint) for i in results) -def test_export_tensorboard_time_series_data_pages(): - client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_export_tensorboard_time_series_data_pages(transport_name: str = "grpc"): + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -9123,7 +9039,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/aiplatform_v1beta1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py index 06287c35d1..e75dd8f0d2 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py @@ -257,20 +257,20 @@ def test_vizier_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -329,7 +329,7 @@ def test_vizier_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -424,7 +424,7 @@ def test_vizier_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -455,7 +455,7 @@ def test_vizier_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -488,9 +488,8 @@ def test_vizier_service_client_client_options_from_dict(): ) -def test_create_study( - transport: str = "grpc", request_type=vizier_service.CreateStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CreateStudyRequest, dict,]) +def test_create_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -523,10 +522,6 @@ def test_create_study( assert response.inactive_reason == "inactive_reason_value" -def test_create_study_from_dict(): - test_create_study(request_type=dict) - - def test_create_study_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 +715,8 @@ async def test_create_study_flattened_error_async(): ) -def test_get_study( - transport: str = "grpc", request_type=vizier_service.GetStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.GetStudyRequest, dict,]) +def test_get_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -755,10 +749,6 @@ def test_get_study( assert response.inactive_reason == "inactive_reason_value" -def test_get_study_from_dict(): - test_get_study(request_type=dict) - - def test_get_study_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. @@ -938,9 +928,8 @@ async def test_get_study_flattened_error_async(): ) -def test_list_studies( - transport: str = "grpc", request_type=vizier_service.ListStudiesRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.ListStudiesRequest, dict,]) +def test_list_studies(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -967,10 +956,6 @@ def test_list_studies( assert response.next_page_token == "next_page_token_value" -def test_list_studies_from_dict(): - test_list_studies(request_type=dict) - - def test_list_studies_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 +1131,10 @@ async def test_list_studies_flattened_error_async(): ) -def test_list_studies_pager(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_studies_pager(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_studies), "__call__") as call: @@ -1180,8 +1167,10 @@ def test_list_studies_pager(): assert all(isinstance(i, study.Study) for i in results) -def test_list_studies_pages(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_studies_pages(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_studies), "__call__") as call: @@ -1268,9 +1257,8 @@ async def test_list_studies_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_study( - transport: str = "grpc", request_type=vizier_service.DeleteStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.DeleteStudyRequest, dict,]) +def test_delete_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1294,10 +1282,6 @@ def test_delete_study( assert response is None -def test_delete_study_from_dict(): - test_delete_study(request_type=dict) - - def test_delete_study_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. @@ -1466,9 +1450,8 @@ async def test_delete_study_flattened_error_async(): ) -def test_lookup_study( - transport: str = "grpc", request_type=vizier_service.LookupStudyRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.LookupStudyRequest, dict,]) +def test_lookup_study(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1501,10 +1484,6 @@ def test_lookup_study( assert response.inactive_reason == "inactive_reason_value" -def test_lookup_study_from_dict(): - test_lookup_study(request_type=dict) - - def test_lookup_study_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. @@ -1684,9 +1663,8 @@ async def test_lookup_study_flattened_error_async(): ) -def test_suggest_trials( - transport: str = "grpc", request_type=vizier_service.SuggestTrialsRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.SuggestTrialsRequest, dict,]) +def test_suggest_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1710,10 +1688,6 @@ def test_suggest_trials( assert isinstance(response, future.Future) -def test_suggest_trials_from_dict(): - test_suggest_trials(request_type=dict) - - def test_suggest_trials_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. @@ -1816,9 +1790,8 @@ async def test_suggest_trials_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_create_trial( - transport: str = "grpc", request_type=vizier_service.CreateTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CreateTrialRequest, dict,]) +def test_create_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1855,10 +1828,6 @@ def test_create_trial( assert response.custom_job == "custom_job_value" -def test_create_trial_from_dict(): - test_create_trial(request_type=dict) - - def test_create_trial_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. @@ -2056,9 +2025,8 @@ async def test_create_trial_flattened_error_async(): ) -def test_get_trial( - transport: str = "grpc", request_type=vizier_service.GetTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.GetTrialRequest, dict,]) +def test_get_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2095,10 +2063,6 @@ def test_get_trial( assert response.custom_job == "custom_job_value" -def test_get_trial_from_dict(): - test_get_trial(request_type=dict) - - def test_get_trial_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. @@ -2282,9 +2246,8 @@ async def test_get_trial_flattened_error_async(): ) -def test_list_trials( - transport: str = "grpc", request_type=vizier_service.ListTrialsRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.ListTrialsRequest, dict,]) +def test_list_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2311,10 +2274,6 @@ def test_list_trials( assert response.next_page_token == "next_page_token_value" -def test_list_trials_from_dict(): - test_list_trials(request_type=dict) - - def test_list_trials_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. @@ -2490,8 +2449,10 @@ async def test_list_trials_flattened_error_async(): ) -def test_list_trials_pager(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_trials_pager(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_trials), "__call__") as call: @@ -2522,8 +2483,10 @@ def test_list_trials_pager(): assert all(isinstance(i, study.Trial) for i in results) -def test_list_trials_pages(): - client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_trials_pages(transport_name: str = "grpc"): + client = VizierServiceClient( + 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_trials), "__call__") as call: @@ -2604,9 +2567,10 @@ async def test_list_trials_async_pages(): assert page_.raw_page.next_page_token == token -def test_add_trial_measurement( - transport: str = "grpc", request_type=vizier_service.AddTrialMeasurementRequest -): +@pytest.mark.parametrize( + "request_type", [vizier_service.AddTrialMeasurementRequest, dict,] +) +def test_add_trial_measurement(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2645,10 +2609,6 @@ def test_add_trial_measurement( assert response.custom_job == "custom_job_value" -def test_add_trial_measurement_from_dict(): - test_add_trial_measurement(request_type=dict) - - def test_add_trial_measurement_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,9 +2731,8 @@ async def test_add_trial_measurement_field_headers_async(): assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] -def test_complete_trial( - transport: str = "grpc", request_type=vizier_service.CompleteTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.CompleteTrialRequest, dict,]) +def test_complete_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2810,10 +2769,6 @@ def test_complete_trial( assert response.custom_job == "custom_job_value" -def test_complete_trial_from_dict(): - test_complete_trial(request_type=dict) - - def test_complete_trial_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. @@ -2927,9 +2882,8 @@ async def test_complete_trial_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_delete_trial( - transport: str = "grpc", request_type=vizier_service.DeleteTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.DeleteTrialRequest, dict,]) +def test_delete_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2953,10 +2907,6 @@ def test_delete_trial( assert response is None -def test_delete_trial_from_dict(): - test_delete_trial(request_type=dict) - - def test_delete_trial_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. @@ -3125,10 +3075,10 @@ async def test_delete_trial_flattened_error_async(): ) -def test_check_trial_early_stopping_state( - transport: str = "grpc", - request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, -): +@pytest.mark.parametrize( + "request_type", [vizier_service.CheckTrialEarlyStoppingStateRequest, dict,] +) +def test_check_trial_early_stopping_state(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3154,10 +3104,6 @@ def test_check_trial_early_stopping_state( assert isinstance(response, future.Future) -def test_check_trial_early_stopping_state_from_dict(): - test_check_trial_early_stopping_state(request_type=dict) - - def test_check_trial_early_stopping_state_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. @@ -3269,9 +3215,8 @@ async def test_check_trial_early_stopping_state_field_headers_async(): assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] -def test_stop_trial( - transport: str = "grpc", request_type=vizier_service.StopTrialRequest -): +@pytest.mark.parametrize("request_type", [vizier_service.StopTrialRequest, dict,]) +def test_stop_trial(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3308,10 +3253,6 @@ def test_stop_trial( assert response.custom_job == "custom_job_value" -def test_stop_trial_from_dict(): - test_stop_trial(request_type=dict) - - def test_stop_trial_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. @@ -3425,9 +3366,10 @@ async def test_stop_trial_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_list_optimal_trials( - transport: str = "grpc", request_type=vizier_service.ListOptimalTrialsRequest -): +@pytest.mark.parametrize( + "request_type", [vizier_service.ListOptimalTrialsRequest, dict,] +) +def test_list_optimal_trials(request_type, transport: str = "grpc"): client = VizierServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3453,10 +3395,6 @@ def test_list_optimal_trials( assert isinstance(response, vizier_service.ListOptimalTrialsResponse) -def test_list_optimal_trials_from_dict(): - test_list_optimal_trials(request_type=dict) - - def test_list_optimal_trials_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. @@ -4251,7 +4189,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(