diff --git a/.librarian/generator-input/client-post-processing/logging-integration.yaml b/.librarian/generator-input/client-post-processing/logging-integration.yaml index 567b536f47be..5aaeae52331c 100644 --- a/.librarian/generator-input/client-post-processing/logging-integration.yaml +++ b/.librarian/generator-input/client-post-processing/logging-integration.yaml @@ -38,15 +38,30 @@ replacements: ] before: | "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0", - \ "grpcio >= 1.44.0, < 2.0.0", + \ "grpcio >= 1.59.0, < 2.0.0", after: | "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0", "google-cloud-appengine-logging>=0.1.3, <2.0.0", "google-cloud-audit-log >= 0.3.1, < 1.0.0", "google-cloud-core >= 2.0.0, <3.0.0", "grpc-google-iam-v1 >=0.12.4, <1.0.0", - "opentelemetry-api >= 1.9.0", - "grpcio >= 1.44.0, < 2.0.0", + "opentelemetry-api >= 1.16.0", + "grpcio >= 1.59.0, < 2.0.0", + count: 1 + - paths: [ + "packages/google-cloud-logging/testing/constraints-3.10.txt" + ] + before: | + google-auth==2.14.1 + grpcio==1.59.0 + after: | + google-auth==2.14.1 + google-cloud-appengine-logging==0.1.3 + google-cloud-audit-log==0.3.1 + google-cloud-core==2.0.0 + grpc-google-iam-v1==0.12.4 + opentelemetry-api==1.16.0 + grpcio==1.59.0 count: 1 - paths: [ "packages/google-cloud-logging/samples/generated_samples/logging_v2_generated_config_service_v2_copy_log_entries_async.py", diff --git a/packages/google-cloud-logging/setup.py b/packages/google-cloud-logging/setup.py index 7ed07b2aefc5..97568c52429b 100644 --- a/packages/google-cloud-logging/setup.py +++ b/packages/google-cloud-logging/setup.py @@ -47,8 +47,8 @@ "google-cloud-audit-log >= 0.3.1, < 1.0.0", "google-cloud-core >= 2.0.0, <3.0.0", "grpc-google-iam-v1 >=0.12.4, <1.0.0", - "opentelemetry-api >= 1.9.0", - "grpcio >= 1.44.0, < 2.0.0", + "opentelemetry-api >= 1.16.0", + "grpcio >= 1.59.0, < 2.0.0", "grpcio >= 1.75.1, < 2.0.0; python_version >= '3.14'", "proto-plus >= 1.22.3, <2.0.0", "proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'", diff --git a/packages/google-cloud-logging/testing/constraints-3.10.txt b/packages/google-cloud-logging/testing/constraints-3.10.txt index bac7ba85b4ee..3ff5c516b82a 100644 --- a/packages/google-cloud-logging/testing/constraints-3.10.txt +++ b/packages/google-cloud-logging/testing/constraints-3.10.txt @@ -6,6 +6,11 @@ # then this file should have google-cloud-foo==1.14.0 google-api-core==2.17.1 google-auth==2.14.1 -grpcio==1.44.0 +google-cloud-appengine-logging==0.1.3 +google-cloud-audit-log==0.3.1 +google-cloud-core==2.0.0 +grpc-google-iam-v1==0.12.4 +opentelemetry-api==1.16.0 +grpcio==1.59.0 proto-plus==1.22.3 protobuf==4.25.8 diff --git a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_config_service_v2.py b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_config_service_v2.py index b4ded2e4b7af..f5ad9afa69ca 100644 --- a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_config_service_v2.py +++ b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_config_service_v2.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import asyncio import json import math import os @@ -70,6 +71,9 @@ "principal": "service-account@example.com", } CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) +_UUID4_RE = re.compile( + r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" +) async def mock_async_gen(data, chunk_size=1): @@ -112,6 +116,21 @@ def modify_default_endpoint_template(client): ) +@pytest.fixture(autouse=True) +def set_event_loop(): + try: + asyncio.get_running_loop() + yield + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + yield + finally: + loop.close() + asyncio.set_event_loop(None) + + def test__get_default_mtls_endpoint(): api_endpoint = "example.googleapis.com" api_mtls_endpoint = "example.mtls.googleapis.com" @@ -1317,8 +1336,8 @@ def test_config_service_v2_client_create_channel_credentials_file( @pytest.mark.parametrize( "request_type", [ - logging_config.ListBucketsRequest, - dict, + logging_config.ListBucketsRequest({}), + {}, ], ) def test_list_buckets(request_type, transport: str = "grpc"): @@ -1329,7 +1348,7 @@ def test_list_buckets(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_buckets), "__call__") as call: @@ -1374,10 +1393,11 @@ def test_list_buckets_non_empty_request_with_auto_populated_field(): client.list_buckets(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.ListBucketsRequest( + request_msg = logging_config.ListBucketsRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_buckets_use_cached_wrapped_rpc(): @@ -1458,9 +1478,14 @@ async def test_list_buckets_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_buckets_async( - transport: str = "grpc_asyncio", request_type=logging_config.ListBucketsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.ListBucketsRequest({}), + {}, + ], +) +async def test_list_buckets_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1468,7 +1493,7 @@ async def test_list_buckets_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_buckets), "__call__") as call: @@ -1491,11 +1516,6 @@ async def test_list_buckets_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_buckets_async_from_dict(): - await test_list_buckets_async(request_type=dict) - - def test_list_buckets_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -1832,8 +1852,8 @@ async def test_list_buckets_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetBucketRequest, - dict, + logging_config.GetBucketRequest({}), + {}, ], ) def test_get_bucket(request_type, transport: str = "grpc"): @@ -1844,7 +1864,7 @@ def test_get_bucket(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_bucket), "__call__") as call: @@ -1900,9 +1920,10 @@ def test_get_bucket_non_empty_request_with_auto_populated_field(): client.get_bucket(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetBucketRequest( + request_msg = logging_config.GetBucketRequest( name="name_value", ) + assert args[0] == request_msg def test_get_bucket_use_cached_wrapped_rpc(): @@ -1981,9 +2002,14 @@ async def test_get_bucket_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_get_bucket_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetBucketRequest({}), + {}, + ], +) +async def test_get_bucket_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1991,7 +2017,7 @@ async def test_get_bucket_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_bucket), "__call__") as call: @@ -2026,11 +2052,6 @@ async def test_get_bucket_async( assert response.restricted_fields == ["restricted_fields_value"] -@pytest.mark.asyncio -async def test_get_bucket_async_from_dict(): - await test_get_bucket_async(request_type=dict) - - def test_get_bucket_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2095,8 +2116,8 @@ async def test_get_bucket_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateBucketRequest, - dict, + logging_config.CreateBucketRequest({}), + {}, ], ) def test_create_bucket_async(request_type, transport: str = "grpc"): @@ -2107,7 +2128,7 @@ def test_create_bucket_async(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2153,10 +2174,11 @@ def test_create_bucket_async_non_empty_request_with_auto_populated_field(): client.create_bucket_async(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateBucketRequest( + request_msg = logging_config.CreateBucketRequest( parent="parent_value", bucket_id="bucket_id_value", ) + assert args[0] == request_msg def test_create_bucket_async_use_cached_wrapped_rpc(): @@ -2251,9 +2273,14 @@ async def test_create_bucket_async_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_bucket_async_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateBucketRequest({}), + {}, + ], +) +async def test_create_bucket_async_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2261,7 +2288,7 @@ async def test_create_bucket_async_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2283,11 +2310,6 @@ async def test_create_bucket_async_async( assert isinstance(response, future.Future) -@pytest.mark.asyncio -async def test_create_bucket_async_async_from_dict(): - await test_create_bucket_async_async(request_type=dict) - - def test_create_bucket_async_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2356,8 +2378,8 @@ async def test_create_bucket_async_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateBucketRequest, - dict, + logging_config.UpdateBucketRequest({}), + {}, ], ) def test_update_bucket_async(request_type, transport: str = "grpc"): @@ -2368,7 +2390,7 @@ def test_update_bucket_async(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2413,9 +2435,10 @@ def test_update_bucket_async_non_empty_request_with_auto_populated_field(): client.update_bucket_async(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateBucketRequest( + request_msg = logging_config.UpdateBucketRequest( name="name_value", ) + assert args[0] == request_msg def test_update_bucket_async_use_cached_wrapped_rpc(): @@ -2510,9 +2533,14 @@ async def test_update_bucket_async_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_bucket_async_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateBucketRequest({}), + {}, + ], +) +async def test_update_bucket_async_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2520,7 +2548,7 @@ async def test_update_bucket_async_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2542,11 +2570,6 @@ async def test_update_bucket_async_async( assert isinstance(response, future.Future) -@pytest.mark.asyncio -async def test_update_bucket_async_async_from_dict(): - await test_update_bucket_async_async(request_type=dict) - - def test_update_bucket_async_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2615,8 +2638,8 @@ async def test_update_bucket_async_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateBucketRequest, - dict, + logging_config.CreateBucketRequest({}), + {}, ], ) def test_create_bucket(request_type, transport: str = "grpc"): @@ -2627,7 +2650,7 @@ def test_create_bucket(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_bucket), "__call__") as call: @@ -2684,10 +2707,11 @@ def test_create_bucket_non_empty_request_with_auto_populated_field(): client.create_bucket(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateBucketRequest( + request_msg = logging_config.CreateBucketRequest( parent="parent_value", bucket_id="bucket_id_value", ) + assert args[0] == request_msg def test_create_bucket_use_cached_wrapped_rpc(): @@ -2768,9 +2792,14 @@ async def test_create_bucket_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_bucket_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateBucketRequest({}), + {}, + ], +) +async def test_create_bucket_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2778,7 +2807,7 @@ async def test_create_bucket_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_bucket), "__call__") as call: @@ -2813,11 +2842,6 @@ async def test_create_bucket_async( assert response.restricted_fields == ["restricted_fields_value"] -@pytest.mark.asyncio -async def test_create_bucket_async_from_dict(): - await test_create_bucket_async(request_type=dict) - - def test_create_bucket_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2882,8 +2906,8 @@ async def test_create_bucket_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateBucketRequest, - dict, + logging_config.UpdateBucketRequest({}), + {}, ], ) def test_update_bucket(request_type, transport: str = "grpc"): @@ -2894,7 +2918,7 @@ def test_update_bucket(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_bucket), "__call__") as call: @@ -2950,9 +2974,10 @@ def test_update_bucket_non_empty_request_with_auto_populated_field(): client.update_bucket(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateBucketRequest( + request_msg = logging_config.UpdateBucketRequest( name="name_value", ) + assert args[0] == request_msg def test_update_bucket_use_cached_wrapped_rpc(): @@ -3033,9 +3058,14 @@ async def test_update_bucket_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_bucket_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateBucketRequest({}), + {}, + ], +) +async def test_update_bucket_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3043,7 +3073,7 @@ async def test_update_bucket_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_bucket), "__call__") as call: @@ -3078,11 +3108,6 @@ async def test_update_bucket_async( assert response.restricted_fields == ["restricted_fields_value"] -@pytest.mark.asyncio -async def test_update_bucket_async_from_dict(): - await test_update_bucket_async(request_type=dict) - - def test_update_bucket_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -3147,8 +3172,8 @@ async def test_update_bucket_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.DeleteBucketRequest, - dict, + logging_config.DeleteBucketRequest({}), + {}, ], ) def test_delete_bucket(request_type, transport: str = "grpc"): @@ -3159,7 +3184,7 @@ def test_delete_bucket(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_bucket), "__call__") as call: @@ -3200,9 +3225,10 @@ def test_delete_bucket_non_empty_request_with_auto_populated_field(): client.delete_bucket(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.DeleteBucketRequest( + request_msg = logging_config.DeleteBucketRequest( name="name_value", ) + assert args[0] == request_msg def test_delete_bucket_use_cached_wrapped_rpc(): @@ -3283,9 +3309,14 @@ async def test_delete_bucket_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_bucket_async( - transport: str = "grpc_asyncio", request_type=logging_config.DeleteBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.DeleteBucketRequest({}), + {}, + ], +) +async def test_delete_bucket_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3293,7 +3324,7 @@ async def test_delete_bucket_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_bucket), "__call__") as call: @@ -3311,11 +3342,6 @@ async def test_delete_bucket_async( assert response is None -@pytest.mark.asyncio -async def test_delete_bucket_async_from_dict(): - await test_delete_bucket_async(request_type=dict) - - def test_delete_bucket_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -3378,8 +3404,8 @@ async def test_delete_bucket_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UndeleteBucketRequest, - dict, + logging_config.UndeleteBucketRequest({}), + {}, ], ) def test_undelete_bucket(request_type, transport: str = "grpc"): @@ -3390,7 +3416,7 @@ def test_undelete_bucket(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undelete_bucket), "__call__") as call: @@ -3431,9 +3457,10 @@ def test_undelete_bucket_non_empty_request_with_auto_populated_field(): client.undelete_bucket(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UndeleteBucketRequest( + request_msg = logging_config.UndeleteBucketRequest( name="name_value", ) + assert args[0] == request_msg def test_undelete_bucket_use_cached_wrapped_rpc(): @@ -3514,9 +3541,14 @@ async def test_undelete_bucket_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_undelete_bucket_async( - transport: str = "grpc_asyncio", request_type=logging_config.UndeleteBucketRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UndeleteBucketRequest({}), + {}, + ], +) +async def test_undelete_bucket_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3524,7 +3556,7 @@ async def test_undelete_bucket_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undelete_bucket), "__call__") as call: @@ -3542,11 +3574,6 @@ async def test_undelete_bucket_async( assert response is None -@pytest.mark.asyncio -async def test_undelete_bucket_async_from_dict(): - await test_undelete_bucket_async(request_type=dict) - - def test_undelete_bucket_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -3609,8 +3636,8 @@ async def test_undelete_bucket_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.ListViewsRequest, - dict, + logging_config.ListViewsRequest({}), + {}, ], ) def test_list_views(request_type, transport: str = "grpc"): @@ -3621,7 +3648,7 @@ def test_list_views(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_views), "__call__") as call: @@ -3666,10 +3693,11 @@ def test_list_views_non_empty_request_with_auto_populated_field(): client.list_views(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.ListViewsRequest( + request_msg = logging_config.ListViewsRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_views_use_cached_wrapped_rpc(): @@ -3748,9 +3776,14 @@ async def test_list_views_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_list_views_async( - transport: str = "grpc_asyncio", request_type=logging_config.ListViewsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.ListViewsRequest({}), + {}, + ], +) +async def test_list_views_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3758,7 +3791,7 @@ async def test_list_views_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_views), "__call__") as call: @@ -3781,11 +3814,6 @@ async def test_list_views_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_views_async_from_dict(): - await test_list_views_async(request_type=dict) - - def test_list_views_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -4122,8 +4150,8 @@ async def test_list_views_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetViewRequest, - dict, + logging_config.GetViewRequest({}), + {}, ], ) def test_get_view(request_type, transport: str = "grpc"): @@ -4134,7 +4162,7 @@ def test_get_view(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_view), "__call__") as call: @@ -4182,9 +4210,10 @@ def test_get_view_non_empty_request_with_auto_populated_field(): client.get_view(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetViewRequest( + request_msg = logging_config.GetViewRequest( name="name_value", ) + assert args[0] == request_msg def test_get_view_use_cached_wrapped_rpc(): @@ -4263,9 +4292,14 @@ async def test_get_view_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn @pytest.mark.asyncio -async def test_get_view_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetViewRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetViewRequest({}), + {}, + ], +) +async def test_get_view_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -4273,7 +4307,7 @@ async def test_get_view_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_view), "__call__") as call: @@ -4300,11 +4334,6 @@ async def test_get_view_async( assert response.filter == "filter_value" -@pytest.mark.asyncio -async def test_get_view_async_from_dict(): - await test_get_view_async(request_type=dict) - - def test_get_view_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -4369,8 +4398,8 @@ async def test_get_view_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateViewRequest, - dict, + logging_config.CreateViewRequest({}), + {}, ], ) def test_create_view(request_type, transport: str = "grpc"): @@ -4381,7 +4410,7 @@ def test_create_view(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_view), "__call__") as call: @@ -4430,10 +4459,11 @@ def test_create_view_non_empty_request_with_auto_populated_field(): client.create_view(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateViewRequest( + request_msg = logging_config.CreateViewRequest( parent="parent_value", view_id="view_id_value", ) + assert args[0] == request_msg def test_create_view_use_cached_wrapped_rpc(): @@ -4514,9 +4544,14 @@ async def test_create_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_view_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateViewRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateViewRequest({}), + {}, + ], +) +async def test_create_view_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -4524,7 +4559,7 @@ async def test_create_view_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_view), "__call__") as call: @@ -4551,11 +4586,6 @@ async def test_create_view_async( assert response.filter == "filter_value" -@pytest.mark.asyncio -async def test_create_view_async_from_dict(): - await test_create_view_async(request_type=dict) - - def test_create_view_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -4620,8 +4650,8 @@ async def test_create_view_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateViewRequest, - dict, + logging_config.UpdateViewRequest({}), + {}, ], ) def test_update_view(request_type, transport: str = "grpc"): @@ -4632,7 +4662,7 @@ def test_update_view(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_view), "__call__") as call: @@ -4680,9 +4710,10 @@ def test_update_view_non_empty_request_with_auto_populated_field(): client.update_view(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateViewRequest( + request_msg = logging_config.UpdateViewRequest( name="name_value", ) + assert args[0] == request_msg def test_update_view_use_cached_wrapped_rpc(): @@ -4763,9 +4794,14 @@ async def test_update_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_view_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateViewRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateViewRequest({}), + {}, + ], +) +async def test_update_view_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -4773,7 +4809,7 @@ async def test_update_view_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_view), "__call__") as call: @@ -4800,11 +4836,6 @@ async def test_update_view_async( assert response.filter == "filter_value" -@pytest.mark.asyncio -async def test_update_view_async_from_dict(): - await test_update_view_async(request_type=dict) - - def test_update_view_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -4869,8 +4900,8 @@ async def test_update_view_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.DeleteViewRequest, - dict, + logging_config.DeleteViewRequest({}), + {}, ], ) def test_delete_view(request_type, transport: str = "grpc"): @@ -4881,7 +4912,7 @@ def test_delete_view(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_view), "__call__") as call: @@ -4922,9 +4953,10 @@ def test_delete_view_non_empty_request_with_auto_populated_field(): client.delete_view(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.DeleteViewRequest( + request_msg = logging_config.DeleteViewRequest( name="name_value", ) + assert args[0] == request_msg def test_delete_view_use_cached_wrapped_rpc(): @@ -5005,9 +5037,14 @@ async def test_delete_view_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_view_async( - transport: str = "grpc_asyncio", request_type=logging_config.DeleteViewRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.DeleteViewRequest({}), + {}, + ], +) +async def test_delete_view_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -5015,7 +5052,7 @@ async def test_delete_view_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_view), "__call__") as call: @@ -5033,11 +5070,6 @@ async def test_delete_view_async( assert response is None -@pytest.mark.asyncio -async def test_delete_view_async_from_dict(): - await test_delete_view_async(request_type=dict) - - def test_delete_view_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -5100,8 +5132,8 @@ async def test_delete_view_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.ListSinksRequest, - dict, + logging_config.ListSinksRequest({}), + {}, ], ) def test_list_sinks(request_type, transport: str = "grpc"): @@ -5112,7 +5144,7 @@ def test_list_sinks(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sinks), "__call__") as call: @@ -5157,10 +5189,11 @@ def test_list_sinks_non_empty_request_with_auto_populated_field(): client.list_sinks(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.ListSinksRequest( + request_msg = logging_config.ListSinksRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_sinks_use_cached_wrapped_rpc(): @@ -5239,9 +5272,14 @@ async def test_list_sinks_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_list_sinks_async( - transport: str = "grpc_asyncio", request_type=logging_config.ListSinksRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.ListSinksRequest({}), + {}, + ], +) +async def test_list_sinks_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -5249,7 +5287,7 @@ async def test_list_sinks_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_sinks), "__call__") as call: @@ -5272,11 +5310,6 @@ async def test_list_sinks_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_sinks_async_from_dict(): - await test_list_sinks_async(request_type=dict) - - def test_list_sinks_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -5613,8 +5646,8 @@ async def test_list_sinks_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetSinkRequest, - dict, + logging_config.GetSinkRequest({}), + {}, ], ) def test_get_sink(request_type, transport: str = "grpc"): @@ -5625,7 +5658,7 @@ def test_get_sink(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_sink), "__call__") as call: @@ -5683,9 +5716,10 @@ def test_get_sink_non_empty_request_with_auto_populated_field(): client.get_sink(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetSinkRequest( + request_msg = logging_config.GetSinkRequest( sink_name="sink_name_value", ) + assert args[0] == request_msg def test_get_sink_use_cached_wrapped_rpc(): @@ -5764,9 +5798,14 @@ async def test_get_sink_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn @pytest.mark.asyncio -async def test_get_sink_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetSinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetSinkRequest({}), + {}, + ], +) +async def test_get_sink_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -5774,7 +5813,7 @@ async def test_get_sink_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_sink), "__call__") as call: @@ -5811,11 +5850,6 @@ async def test_get_sink_async( assert response.include_children is True -@pytest.mark.asyncio -async def test_get_sink_async_from_dict(): - await test_get_sink_async(request_type=dict) - - def test_get_sink_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -5962,8 +5996,8 @@ async def test_get_sink_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateSinkRequest, - dict, + logging_config.CreateSinkRequest({}), + {}, ], ) def test_create_sink(request_type, transport: str = "grpc"): @@ -5974,7 +6008,7 @@ def test_create_sink(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_sink), "__call__") as call: @@ -6032,9 +6066,10 @@ def test_create_sink_non_empty_request_with_auto_populated_field(): client.create_sink(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateSinkRequest( + request_msg = logging_config.CreateSinkRequest( parent="parent_value", ) + assert args[0] == request_msg def test_create_sink_use_cached_wrapped_rpc(): @@ -6115,9 +6150,14 @@ async def test_create_sink_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_sink_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateSinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateSinkRequest({}), + {}, + ], +) +async def test_create_sink_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -6125,7 +6165,7 @@ async def test_create_sink_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_sink), "__call__") as call: @@ -6162,11 +6202,6 @@ async def test_create_sink_async( assert response.include_children is True -@pytest.mark.asyncio -async def test_create_sink_async_from_dict(): - await test_create_sink_async(request_type=dict) - - def test_create_sink_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -6323,8 +6358,8 @@ async def test_create_sink_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateSinkRequest, - dict, + logging_config.UpdateSinkRequest({}), + {}, ], ) def test_update_sink(request_type, transport: str = "grpc"): @@ -6335,7 +6370,7 @@ def test_update_sink(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_sink), "__call__") as call: @@ -6393,9 +6428,10 @@ def test_update_sink_non_empty_request_with_auto_populated_field(): client.update_sink(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateSinkRequest( + request_msg = logging_config.UpdateSinkRequest( sink_name="sink_name_value", ) + assert args[0] == request_msg def test_update_sink_use_cached_wrapped_rpc(): @@ -6476,9 +6512,14 @@ async def test_update_sink_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_sink_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateSinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateSinkRequest({}), + {}, + ], +) +async def test_update_sink_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -6486,7 +6527,7 @@ async def test_update_sink_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_sink), "__call__") as call: @@ -6523,11 +6564,6 @@ async def test_update_sink_async( assert response.include_children is True -@pytest.mark.asyncio -async def test_update_sink_async_from_dict(): - await test_update_sink_async(request_type=dict) - - def test_update_sink_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -6694,8 +6730,8 @@ async def test_update_sink_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.DeleteSinkRequest, - dict, + logging_config.DeleteSinkRequest({}), + {}, ], ) def test_delete_sink(request_type, transport: str = "grpc"): @@ -6706,7 +6742,7 @@ def test_delete_sink(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_sink), "__call__") as call: @@ -6747,9 +6783,10 @@ def test_delete_sink_non_empty_request_with_auto_populated_field(): client.delete_sink(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.DeleteSinkRequest( + request_msg = logging_config.DeleteSinkRequest( sink_name="sink_name_value", ) + assert args[0] == request_msg def test_delete_sink_use_cached_wrapped_rpc(): @@ -6830,9 +6867,14 @@ async def test_delete_sink_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_sink_async( - transport: str = "grpc_asyncio", request_type=logging_config.DeleteSinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.DeleteSinkRequest({}), + {}, + ], +) +async def test_delete_sink_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -6840,7 +6882,7 @@ async def test_delete_sink_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_sink), "__call__") as call: @@ -6858,11 +6900,6 @@ async def test_delete_sink_async( assert response is None -@pytest.mark.asyncio -async def test_delete_sink_async_from_dict(): - await test_delete_sink_async(request_type=dict) - - def test_delete_sink_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -7005,8 +7042,8 @@ async def test_delete_sink_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateLinkRequest, - dict, + logging_config.CreateLinkRequest({}), + {}, ], ) def test_create_link(request_type, transport: str = "grpc"): @@ -7017,7 +7054,7 @@ def test_create_link(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_link), "__call__") as call: @@ -7059,10 +7096,11 @@ def test_create_link_non_empty_request_with_auto_populated_field(): client.create_link(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateLinkRequest( + request_msg = logging_config.CreateLinkRequest( parent="parent_value", link_id="link_id_value", ) + assert args[0] == request_msg def test_create_link_use_cached_wrapped_rpc(): @@ -7153,9 +7191,14 @@ async def test_create_link_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_link_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateLinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateLinkRequest({}), + {}, + ], +) +async def test_create_link_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -7163,7 +7206,7 @@ async def test_create_link_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_link), "__call__") as call: @@ -7183,11 +7226,6 @@ async def test_create_link_async( assert isinstance(response, future.Future) -@pytest.mark.asyncio -async def test_create_link_async_from_dict(): - await test_create_link_async(request_type=dict) - - def test_create_link_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -7354,8 +7392,8 @@ async def test_create_link_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.DeleteLinkRequest, - dict, + logging_config.DeleteLinkRequest({}), + {}, ], ) def test_delete_link(request_type, transport: str = "grpc"): @@ -7366,7 +7404,7 @@ def test_delete_link(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_link), "__call__") as call: @@ -7407,9 +7445,10 @@ def test_delete_link_non_empty_request_with_auto_populated_field(): client.delete_link(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.DeleteLinkRequest( + request_msg = logging_config.DeleteLinkRequest( name="name_value", ) + assert args[0] == request_msg def test_delete_link_use_cached_wrapped_rpc(): @@ -7500,9 +7539,14 @@ async def test_delete_link_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_link_async( - transport: str = "grpc_asyncio", request_type=logging_config.DeleteLinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.DeleteLinkRequest({}), + {}, + ], +) +async def test_delete_link_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -7510,7 +7554,7 @@ async def test_delete_link_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_link), "__call__") as call: @@ -7530,11 +7574,6 @@ async def test_delete_link_async( assert isinstance(response, future.Future) -@pytest.mark.asyncio -async def test_delete_link_async_from_dict(): - await test_delete_link_async(request_type=dict) - - def test_delete_link_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -7681,8 +7720,8 @@ async def test_delete_link_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.ListLinksRequest, - dict, + logging_config.ListLinksRequest({}), + {}, ], ) def test_list_links(request_type, transport: str = "grpc"): @@ -7693,7 +7732,7 @@ def test_list_links(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_links), "__call__") as call: @@ -7738,10 +7777,11 @@ def test_list_links_non_empty_request_with_auto_populated_field(): client.list_links(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.ListLinksRequest( + request_msg = logging_config.ListLinksRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_links_use_cached_wrapped_rpc(): @@ -7820,9 +7860,14 @@ async def test_list_links_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_list_links_async( - transport: str = "grpc_asyncio", request_type=logging_config.ListLinksRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.ListLinksRequest({}), + {}, + ], +) +async def test_list_links_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -7830,7 +7875,7 @@ async def test_list_links_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_links), "__call__") as call: @@ -7853,11 +7898,6 @@ async def test_list_links_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_links_async_from_dict(): - await test_list_links_async(request_type=dict) - - def test_list_links_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -8194,8 +8234,8 @@ async def test_list_links_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetLinkRequest, - dict, + logging_config.GetLinkRequest({}), + {}, ], ) def test_get_link(request_type, transport: str = "grpc"): @@ -8206,7 +8246,7 @@ def test_get_link(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_link), "__call__") as call: @@ -8254,9 +8294,10 @@ def test_get_link_non_empty_request_with_auto_populated_field(): client.get_link(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetLinkRequest( + request_msg = logging_config.GetLinkRequest( name="name_value", ) + assert args[0] == request_msg def test_get_link_use_cached_wrapped_rpc(): @@ -8335,9 +8376,14 @@ async def test_get_link_async_use_cached_wrapped_rpc(transport: str = "grpc_asyn @pytest.mark.asyncio -async def test_get_link_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetLinkRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetLinkRequest({}), + {}, + ], +) +async def test_get_link_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -8345,7 +8391,7 @@ async def test_get_link_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_link), "__call__") as call: @@ -8372,11 +8418,6 @@ async def test_get_link_async( assert response.lifecycle_state == logging_config.LifecycleState.ACTIVE -@pytest.mark.asyncio -async def test_get_link_async_from_dict(): - await test_get_link_async(request_type=dict) - - def test_get_link_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -8519,8 +8560,8 @@ async def test_get_link_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.ListExclusionsRequest, - dict, + logging_config.ListExclusionsRequest({}), + {}, ], ) def test_list_exclusions(request_type, transport: str = "grpc"): @@ -8531,7 +8572,7 @@ def test_list_exclusions(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_exclusions), "__call__") as call: @@ -8576,10 +8617,11 @@ def test_list_exclusions_non_empty_request_with_auto_populated_field(): client.list_exclusions(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.ListExclusionsRequest( + request_msg = logging_config.ListExclusionsRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_exclusions_use_cached_wrapped_rpc(): @@ -8660,9 +8702,14 @@ async def test_list_exclusions_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_exclusions_async( - transport: str = "grpc_asyncio", request_type=logging_config.ListExclusionsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.ListExclusionsRequest({}), + {}, + ], +) +async def test_list_exclusions_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -8670,7 +8717,7 @@ async def test_list_exclusions_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_exclusions), "__call__") as call: @@ -8693,11 +8740,6 @@ async def test_list_exclusions_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_exclusions_async_from_dict(): - await test_list_exclusions_async(request_type=dict) - - def test_list_exclusions_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -9034,8 +9076,8 @@ async def test_list_exclusions_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetExclusionRequest, - dict, + logging_config.GetExclusionRequest({}), + {}, ], ) def test_get_exclusion(request_type, transport: str = "grpc"): @@ -9046,7 +9088,7 @@ def test_get_exclusion(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_exclusion), "__call__") as call: @@ -9096,9 +9138,10 @@ def test_get_exclusion_non_empty_request_with_auto_populated_field(): client.get_exclusion(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetExclusionRequest( + request_msg = logging_config.GetExclusionRequest( name="name_value", ) + assert args[0] == request_msg def test_get_exclusion_use_cached_wrapped_rpc(): @@ -9179,9 +9222,14 @@ async def test_get_exclusion_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_exclusion_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetExclusionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetExclusionRequest({}), + {}, + ], +) +async def test_get_exclusion_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -9189,7 +9237,7 @@ async def test_get_exclusion_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_exclusion), "__call__") as call: @@ -9218,11 +9266,6 @@ async def test_get_exclusion_async( assert response.disabled is True -@pytest.mark.asyncio -async def test_get_exclusion_async_from_dict(): - await test_get_exclusion_async(request_type=dict) - - def test_get_exclusion_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -9369,8 +9412,8 @@ async def test_get_exclusion_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CreateExclusionRequest, - dict, + logging_config.CreateExclusionRequest({}), + {}, ], ) def test_create_exclusion(request_type, transport: str = "grpc"): @@ -9381,7 +9424,7 @@ def test_create_exclusion(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_exclusion), "__call__") as call: @@ -9431,9 +9474,10 @@ def test_create_exclusion_non_empty_request_with_auto_populated_field(): client.create_exclusion(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CreateExclusionRequest( + request_msg = logging_config.CreateExclusionRequest( parent="parent_value", ) + assert args[0] == request_msg def test_create_exclusion_use_cached_wrapped_rpc(): @@ -9516,9 +9560,14 @@ async def test_create_exclusion_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_exclusion_async( - transport: str = "grpc_asyncio", request_type=logging_config.CreateExclusionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CreateExclusionRequest({}), + {}, + ], +) +async def test_create_exclusion_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -9526,7 +9575,7 @@ async def test_create_exclusion_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_exclusion), "__call__") as call: @@ -9555,11 +9604,6 @@ async def test_create_exclusion_async( assert response.disabled is True -@pytest.mark.asyncio -async def test_create_exclusion_async_from_dict(): - await test_create_exclusion_async(request_type=dict) - - def test_create_exclusion_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -9716,8 +9760,8 @@ async def test_create_exclusion_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateExclusionRequest, - dict, + logging_config.UpdateExclusionRequest({}), + {}, ], ) def test_update_exclusion(request_type, transport: str = "grpc"): @@ -9728,7 +9772,7 @@ def test_update_exclusion(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_exclusion), "__call__") as call: @@ -9778,9 +9822,10 @@ def test_update_exclusion_non_empty_request_with_auto_populated_field(): client.update_exclusion(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateExclusionRequest( + request_msg = logging_config.UpdateExclusionRequest( name="name_value", ) + assert args[0] == request_msg def test_update_exclusion_use_cached_wrapped_rpc(): @@ -9863,9 +9908,14 @@ async def test_update_exclusion_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_exclusion_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateExclusionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateExclusionRequest({}), + {}, + ], +) +async def test_update_exclusion_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -9873,7 +9923,7 @@ async def test_update_exclusion_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_exclusion), "__call__") as call: @@ -9902,11 +9952,6 @@ async def test_update_exclusion_async( assert response.disabled is True -@pytest.mark.asyncio -async def test_update_exclusion_async_from_dict(): - await test_update_exclusion_async(request_type=dict) - - def test_update_exclusion_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -10073,8 +10118,8 @@ async def test_update_exclusion_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.DeleteExclusionRequest, - dict, + logging_config.DeleteExclusionRequest({}), + {}, ], ) def test_delete_exclusion(request_type, transport: str = "grpc"): @@ -10085,7 +10130,7 @@ def test_delete_exclusion(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_exclusion), "__call__") as call: @@ -10126,9 +10171,10 @@ def test_delete_exclusion_non_empty_request_with_auto_populated_field(): client.delete_exclusion(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.DeleteExclusionRequest( + request_msg = logging_config.DeleteExclusionRequest( name="name_value", ) + assert args[0] == request_msg def test_delete_exclusion_use_cached_wrapped_rpc(): @@ -10211,9 +10257,14 @@ async def test_delete_exclusion_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_exclusion_async( - transport: str = "grpc_asyncio", request_type=logging_config.DeleteExclusionRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.DeleteExclusionRequest({}), + {}, + ], +) +async def test_delete_exclusion_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -10221,7 +10272,7 @@ async def test_delete_exclusion_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_exclusion), "__call__") as call: @@ -10239,11 +10290,6 @@ async def test_delete_exclusion_async( assert response is None -@pytest.mark.asyncio -async def test_delete_exclusion_async_from_dict(): - await test_delete_exclusion_async(request_type=dict) - - def test_delete_exclusion_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -10386,8 +10432,8 @@ async def test_delete_exclusion_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetCmekSettingsRequest, - dict, + logging_config.GetCmekSettingsRequest({}), + {}, ], ) def test_get_cmek_settings(request_type, transport: str = "grpc"): @@ -10398,7 +10444,7 @@ def test_get_cmek_settings(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -10452,9 +10498,10 @@ def test_get_cmek_settings_non_empty_request_with_auto_populated_field(): client.get_cmek_settings(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetCmekSettingsRequest( + request_msg = logging_config.GetCmekSettingsRequest( name="name_value", ) + assert args[0] == request_msg def test_get_cmek_settings_use_cached_wrapped_rpc(): @@ -10537,9 +10584,14 @@ async def test_get_cmek_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_cmek_settings_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetCmekSettingsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetCmekSettingsRequest({}), + {}, + ], +) +async def test_get_cmek_settings_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -10547,7 +10599,7 @@ async def test_get_cmek_settings_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -10578,11 +10630,6 @@ async def test_get_cmek_settings_async( assert response.service_account_id == "service_account_id_value" -@pytest.mark.asyncio -async def test_get_cmek_settings_async_from_dict(): - await test_get_cmek_settings_async(request_type=dict) - - def test_get_cmek_settings_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -10651,8 +10698,8 @@ async def test_get_cmek_settings_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateCmekSettingsRequest, - dict, + logging_config.UpdateCmekSettingsRequest({}), + {}, ], ) def test_update_cmek_settings(request_type, transport: str = "grpc"): @@ -10663,7 +10710,7 @@ def test_update_cmek_settings(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -10717,9 +10764,10 @@ def test_update_cmek_settings_non_empty_request_with_auto_populated_field(): client.update_cmek_settings(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateCmekSettingsRequest( + request_msg = logging_config.UpdateCmekSettingsRequest( name="name_value", ) + assert args[0] == request_msg def test_update_cmek_settings_use_cached_wrapped_rpc(): @@ -10804,9 +10852,15 @@ async def test_update_cmek_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateCmekSettingsRequest({}), + {}, + ], +) async def test_update_cmek_settings_async( - transport: str = "grpc_asyncio", - request_type=logging_config.UpdateCmekSettingsRequest, + request_type, transport: str = "grpc_asyncio" ): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), @@ -10815,7 +10869,7 @@ async def test_update_cmek_settings_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -10846,11 +10900,6 @@ async def test_update_cmek_settings_async( assert response.service_account_id == "service_account_id_value" -@pytest.mark.asyncio -async def test_update_cmek_settings_async_from_dict(): - await test_update_cmek_settings_async(request_type=dict) - - def test_update_cmek_settings_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -10919,8 +10968,8 @@ async def test_update_cmek_settings_field_headers_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.GetSettingsRequest, - dict, + logging_config.GetSettingsRequest({}), + {}, ], ) def test_get_settings(request_type, transport: str = "grpc"): @@ -10931,7 +10980,7 @@ def test_get_settings(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_settings), "__call__") as call: @@ -10983,9 +11032,10 @@ def test_get_settings_non_empty_request_with_auto_populated_field(): client.get_settings(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.GetSettingsRequest( + request_msg = logging_config.GetSettingsRequest( name="name_value", ) + assert args[0] == request_msg def test_get_settings_use_cached_wrapped_rpc(): @@ -11066,9 +11116,14 @@ async def test_get_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_settings_async( - transport: str = "grpc_asyncio", request_type=logging_config.GetSettingsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.GetSettingsRequest({}), + {}, + ], +) +async def test_get_settings_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -11076,7 +11131,7 @@ async def test_get_settings_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_settings), "__call__") as call: @@ -11107,11 +11162,6 @@ async def test_get_settings_async( assert response.disable_default_sink is True -@pytest.mark.asyncio -async def test_get_settings_async_from_dict(): - await test_get_settings_async(request_type=dict) - - def test_get_settings_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -11258,8 +11308,8 @@ async def test_get_settings_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.UpdateSettingsRequest, - dict, + logging_config.UpdateSettingsRequest({}), + {}, ], ) def test_update_settings(request_type, transport: str = "grpc"): @@ -11270,7 +11320,7 @@ def test_update_settings(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_settings), "__call__") as call: @@ -11322,9 +11372,10 @@ def test_update_settings_non_empty_request_with_auto_populated_field(): client.update_settings(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.UpdateSettingsRequest( + request_msg = logging_config.UpdateSettingsRequest( name="name_value", ) + assert args[0] == request_msg def test_update_settings_use_cached_wrapped_rpc(): @@ -11405,9 +11456,14 @@ async def test_update_settings_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_settings_async( - transport: str = "grpc_asyncio", request_type=logging_config.UpdateSettingsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.UpdateSettingsRequest({}), + {}, + ], +) +async def test_update_settings_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -11415,7 +11471,7 @@ async def test_update_settings_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_settings), "__call__") as call: @@ -11446,11 +11502,6 @@ async def test_update_settings_async( assert response.disable_default_sink is True -@pytest.mark.asyncio -async def test_update_settings_async_from_dict(): - await test_update_settings_async(request_type=dict) - - def test_update_settings_field_headers(): client = ConfigServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -11607,8 +11658,8 @@ async def test_update_settings_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_config.CopyLogEntriesRequest, - dict, + logging_config.CopyLogEntriesRequest({}), + {}, ], ) def test_copy_log_entries(request_type, transport: str = "grpc"): @@ -11619,7 +11670,7 @@ def test_copy_log_entries(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.copy_log_entries), "__call__") as call: @@ -11662,11 +11713,12 @@ def test_copy_log_entries_non_empty_request_with_auto_populated_field(): client.copy_log_entries(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_config.CopyLogEntriesRequest( + request_msg = logging_config.CopyLogEntriesRequest( name="name_value", filter="filter_value", destination="destination_value", ) + assert args[0] == request_msg def test_copy_log_entries_use_cached_wrapped_rpc(): @@ -11759,9 +11811,14 @@ async def test_copy_log_entries_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_copy_log_entries_async( - transport: str = "grpc_asyncio", request_type=logging_config.CopyLogEntriesRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_config.CopyLogEntriesRequest({}), + {}, + ], +) +async def test_copy_log_entries_async(request_type, transport: str = "grpc_asyncio"): client = ConfigServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -11769,7 +11826,7 @@ async def test_copy_log_entries_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.copy_log_entries), "__call__") as call: @@ -11789,11 +11846,6 @@ async def test_copy_log_entries_async( assert isinstance(response, future.Future) -@pytest.mark.asyncio -async def test_copy_log_entries_async_from_dict(): - await test_copy_log_entries_async(request_type=dict) - - def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ConfigServiceV2GrpcTransport( @@ -11916,7 +11968,6 @@ def test_list_buckets_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListBucketsRequest() - assert args[0] == request_msg @@ -11937,7 +11988,6 @@ def test_get_bucket_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetBucketRequest() - assert args[0] == request_msg @@ -11960,7 +12010,6 @@ def test_create_bucket_async_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateBucketRequest() - assert args[0] == request_msg @@ -11983,7 +12032,6 @@ def test_update_bucket_async_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateBucketRequest() - assert args[0] == request_msg @@ -12004,7 +12052,6 @@ def test_create_bucket_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateBucketRequest() - assert args[0] == request_msg @@ -12025,7 +12072,6 @@ def test_update_bucket_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateBucketRequest() - assert args[0] == request_msg @@ -12046,7 +12092,6 @@ def test_delete_bucket_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteBucketRequest() - assert args[0] == request_msg @@ -12067,7 +12112,6 @@ def test_undelete_bucket_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UndeleteBucketRequest() - assert args[0] == request_msg @@ -12088,7 +12132,6 @@ def test_list_views_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListViewsRequest() - assert args[0] == request_msg @@ -12109,7 +12152,6 @@ def test_get_view_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetViewRequest() - assert args[0] == request_msg @@ -12130,7 +12172,6 @@ def test_create_view_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateViewRequest() - assert args[0] == request_msg @@ -12151,7 +12192,6 @@ def test_update_view_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateViewRequest() - assert args[0] == request_msg @@ -12172,7 +12212,6 @@ def test_delete_view_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteViewRequest() - assert args[0] == request_msg @@ -12193,7 +12232,6 @@ def test_list_sinks_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListSinksRequest() - assert args[0] == request_msg @@ -12214,7 +12252,6 @@ def test_get_sink_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetSinkRequest() - assert args[0] == request_msg @@ -12235,7 +12272,6 @@ def test_create_sink_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateSinkRequest() - assert args[0] == request_msg @@ -12256,7 +12292,6 @@ def test_update_sink_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateSinkRequest() - assert args[0] == request_msg @@ -12277,7 +12312,6 @@ def test_delete_sink_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteSinkRequest() - assert args[0] == request_msg @@ -12298,7 +12332,6 @@ def test_create_link_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateLinkRequest() - assert args[0] == request_msg @@ -12319,7 +12352,6 @@ def test_delete_link_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteLinkRequest() - assert args[0] == request_msg @@ -12340,7 +12372,6 @@ def test_list_links_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListLinksRequest() - assert args[0] == request_msg @@ -12361,7 +12392,6 @@ def test_get_link_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetLinkRequest() - assert args[0] == request_msg @@ -12382,7 +12412,6 @@ def test_list_exclusions_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListExclusionsRequest() - assert args[0] == request_msg @@ -12403,7 +12432,6 @@ def test_get_exclusion_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetExclusionRequest() - assert args[0] == request_msg @@ -12424,7 +12452,6 @@ def test_create_exclusion_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateExclusionRequest() - assert args[0] == request_msg @@ -12445,7 +12472,6 @@ def test_update_exclusion_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateExclusionRequest() - assert args[0] == request_msg @@ -12466,7 +12492,6 @@ def test_delete_exclusion_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteExclusionRequest() - assert args[0] == request_msg @@ -12489,7 +12514,6 @@ def test_get_cmek_settings_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetCmekSettingsRequest() - assert args[0] == request_msg @@ -12512,7 +12536,6 @@ def test_update_cmek_settings_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateCmekSettingsRequest() - assert args[0] == request_msg @@ -12533,7 +12556,6 @@ def test_get_settings_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetSettingsRequest() - assert args[0] == request_msg @@ -12554,7 +12576,6 @@ def test_update_settings_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateSettingsRequest() - assert args[0] == request_msg @@ -12575,7 +12596,6 @@ def test_copy_log_entries_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CopyLogEntriesRequest() - assert args[0] == request_msg @@ -12616,7 +12636,6 @@ async def test_list_buckets_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListBucketsRequest() - assert args[0] == request_msg @@ -12649,7 +12668,6 @@ async def test_get_bucket_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetBucketRequest() - assert args[0] == request_msg @@ -12676,7 +12694,6 @@ async def test_create_bucket_async_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateBucketRequest() - assert args[0] == request_msg @@ -12703,7 +12720,6 @@ async def test_update_bucket_async_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateBucketRequest() - assert args[0] == request_msg @@ -12736,7 +12752,6 @@ async def test_create_bucket_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateBucketRequest() - assert args[0] == request_msg @@ -12769,7 +12784,6 @@ async def test_update_bucket_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateBucketRequest() - assert args[0] == request_msg @@ -12792,7 +12806,6 @@ async def test_delete_bucket_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteBucketRequest() - assert args[0] == request_msg @@ -12815,7 +12828,6 @@ async def test_undelete_bucket_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UndeleteBucketRequest() - assert args[0] == request_msg @@ -12842,7 +12854,6 @@ async def test_list_views_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListViewsRequest() - assert args[0] == request_msg @@ -12871,7 +12882,6 @@ async def test_get_view_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetViewRequest() - assert args[0] == request_msg @@ -12900,7 +12910,6 @@ async def test_create_view_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateViewRequest() - assert args[0] == request_msg @@ -12929,7 +12938,6 @@ async def test_update_view_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateViewRequest() - assert args[0] == request_msg @@ -12952,7 +12960,6 @@ async def test_delete_view_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteViewRequest() - assert args[0] == request_msg @@ -12979,7 +12986,6 @@ async def test_list_sinks_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListSinksRequest() - assert args[0] == request_msg @@ -13013,7 +13019,6 @@ async def test_get_sink_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetSinkRequest() - assert args[0] == request_msg @@ -13047,7 +13052,6 @@ async def test_create_sink_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateSinkRequest() - assert args[0] == request_msg @@ -13081,7 +13085,6 @@ async def test_update_sink_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateSinkRequest() - assert args[0] == request_msg @@ -13104,7 +13107,6 @@ async def test_delete_sink_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteSinkRequest() - assert args[0] == request_msg @@ -13129,7 +13131,6 @@ async def test_create_link_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateLinkRequest() - assert args[0] == request_msg @@ -13154,7 +13155,6 @@ async def test_delete_link_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteLinkRequest() - assert args[0] == request_msg @@ -13181,7 +13181,6 @@ async def test_list_links_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListLinksRequest() - assert args[0] == request_msg @@ -13210,7 +13209,6 @@ async def test_get_link_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetLinkRequest() - assert args[0] == request_msg @@ -13237,7 +13235,6 @@ async def test_list_exclusions_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.ListExclusionsRequest() - assert args[0] == request_msg @@ -13267,7 +13264,6 @@ async def test_get_exclusion_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetExclusionRequest() - assert args[0] == request_msg @@ -13297,7 +13293,6 @@ async def test_create_exclusion_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CreateExclusionRequest() - assert args[0] == request_msg @@ -13327,7 +13322,6 @@ async def test_update_exclusion_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateExclusionRequest() - assert args[0] == request_msg @@ -13350,7 +13344,6 @@ async def test_delete_exclusion_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.DeleteExclusionRequest() - assert args[0] == request_msg @@ -13382,7 +13375,6 @@ async def test_get_cmek_settings_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetCmekSettingsRequest() - assert args[0] == request_msg @@ -13414,7 +13406,6 @@ async def test_update_cmek_settings_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateCmekSettingsRequest() - assert args[0] == request_msg @@ -13445,7 +13436,6 @@ async def test_get_settings_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.GetSettingsRequest() - assert args[0] == request_msg @@ -13476,7 +13466,6 @@ async def test_update_settings_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.UpdateSettingsRequest() - assert args[0] == request_msg @@ -13501,7 +13490,6 @@ async def test_copy_log_entries_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_config.CopyLogEntriesRequest() - assert args[0] == request_msg diff --git a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py index 15fc2e936161..a7996c112686 100644 --- a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py +++ b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import asyncio import json import math import os @@ -70,6 +71,9 @@ "principal": "service-account@example.com", } CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) +_UUID4_RE = re.compile( + r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" +) async def mock_async_gen(data, chunk_size=1): @@ -112,6 +116,21 @@ def modify_default_endpoint_template(client): ) +@pytest.fixture(autouse=True) +def set_event_loop(): + try: + asyncio.get_running_loop() + yield + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + yield + finally: + loop.close() + asyncio.set_event_loop(None) + + def test__get_default_mtls_endpoint(): api_endpoint = "example.googleapis.com" api_mtls_endpoint = "example.mtls.googleapis.com" @@ -1319,8 +1338,8 @@ def test_logging_service_v2_client_create_channel_credentials_file( @pytest.mark.parametrize( "request_type", [ - logging.DeleteLogRequest, - dict, + logging.DeleteLogRequest({}), + {}, ], ) def test_delete_log(request_type, transport: str = "grpc"): @@ -1331,7 +1350,7 @@ def test_delete_log(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_log), "__call__") as call: @@ -1372,9 +1391,10 @@ def test_delete_log_non_empty_request_with_auto_populated_field(): client.delete_log(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging.DeleteLogRequest( + request_msg = logging.DeleteLogRequest( log_name="log_name_value", ) + assert args[0] == request_msg def test_delete_log_use_cached_wrapped_rpc(): @@ -1453,9 +1473,14 @@ async def test_delete_log_async_use_cached_wrapped_rpc(transport: str = "grpc_as @pytest.mark.asyncio -async def test_delete_log_async( - transport: str = "grpc_asyncio", request_type=logging.DeleteLogRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging.DeleteLogRequest({}), + {}, + ], +) +async def test_delete_log_async(request_type, transport: str = "grpc_asyncio"): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1463,7 +1488,7 @@ async def test_delete_log_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_log), "__call__") as call: @@ -1481,11 +1506,6 @@ async def test_delete_log_async( assert response is None -@pytest.mark.asyncio -async def test_delete_log_async_from_dict(): - await test_delete_log_async(request_type=dict) - - def test_delete_log_field_headers(): client = LoggingServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -1628,8 +1648,8 @@ async def test_delete_log_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging.WriteLogEntriesRequest, - dict, + logging.WriteLogEntriesRequest({}), + {}, ], ) def test_write_log_entries(request_type, transport: str = "grpc"): @@ -1640,7 +1660,7 @@ def test_write_log_entries(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1685,9 +1705,10 @@ def test_write_log_entries_non_empty_request_with_auto_populated_field(): client.write_log_entries(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging.WriteLogEntriesRequest( + request_msg = logging.WriteLogEntriesRequest( log_name="log_name_value", ) + assert args[0] == request_msg def test_write_log_entries_use_cached_wrapped_rpc(): @@ -1770,9 +1791,14 @@ async def test_write_log_entries_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_write_log_entries_async( - transport: str = "grpc_asyncio", request_type=logging.WriteLogEntriesRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging.WriteLogEntriesRequest({}), + {}, + ], +) +async def test_write_log_entries_async(request_type, transport: str = "grpc_asyncio"): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1780,7 +1806,7 @@ async def test_write_log_entries_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1802,11 +1828,6 @@ async def test_write_log_entries_async( assert isinstance(response, logging.WriteLogEntriesResponse) -@pytest.mark.asyncio -async def test_write_log_entries_async_from_dict(): - await test_write_log_entries_async(request_type=dict) - - def test_write_log_entries_flattened(): client = LoggingServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -1926,8 +1947,8 @@ async def test_write_log_entries_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging.ListLogEntriesRequest, - dict, + logging.ListLogEntriesRequest({}), + {}, ], ) def test_list_log_entries(request_type, transport: str = "grpc"): @@ -1938,7 +1959,7 @@ def test_list_log_entries(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_log_entries), "__call__") as call: @@ -1984,11 +2005,12 @@ def test_list_log_entries_non_empty_request_with_auto_populated_field(): client.list_log_entries(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging.ListLogEntriesRequest( + request_msg = logging.ListLogEntriesRequest( filter="filter_value", order_by="order_by_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_log_entries_use_cached_wrapped_rpc(): @@ -2071,9 +2093,14 @@ async def test_list_log_entries_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_log_entries_async( - transport: str = "grpc_asyncio", request_type=logging.ListLogEntriesRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging.ListLogEntriesRequest({}), + {}, + ], +) +async def test_list_log_entries_async(request_type, transport: str = "grpc_asyncio"): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2081,7 +2108,7 @@ async def test_list_log_entries_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_log_entries), "__call__") as call: @@ -2104,11 +2131,6 @@ async def test_list_log_entries_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_log_entries_async_from_dict(): - await test_list_log_entries_async(request_type=dict) - - def test_list_log_entries_flattened(): client = LoggingServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2401,8 +2423,8 @@ async def test_list_log_entries_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging.ListMonitoredResourceDescriptorsRequest, - dict, + logging.ListMonitoredResourceDescriptorsRequest({}), + {}, ], ) def test_list_monitored_resource_descriptors(request_type, transport: str = "grpc"): @@ -2413,7 +2435,7 @@ def test_list_monitored_resource_descriptors(request_type, transport: str = "grp # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2461,9 +2483,10 @@ def test_list_monitored_resource_descriptors_non_empty_request_with_auto_populat client.list_monitored_resource_descriptors(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging.ListMonitoredResourceDescriptorsRequest( + request_msg = logging.ListMonitoredResourceDescriptorsRequest( page_token="page_token_value", ) + assert args[0] == request_msg def test_list_monitored_resource_descriptors_use_cached_wrapped_rpc(): @@ -2549,9 +2572,15 @@ async def test_list_monitored_resource_descriptors_async_use_cached_wrapped_rpc( @pytest.mark.asyncio +@pytest.mark.parametrize( + "request_type", + [ + logging.ListMonitoredResourceDescriptorsRequest({}), + {}, + ], +) async def test_list_monitored_resource_descriptors_async( - transport: str = "grpc_asyncio", - request_type=logging.ListMonitoredResourceDescriptorsRequest, + request_type, transport: str = "grpc_asyncio" ): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), @@ -2560,7 +2589,7 @@ async def test_list_monitored_resource_descriptors_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2585,11 +2614,6 @@ async def test_list_monitored_resource_descriptors_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_monitored_resource_descriptors_async_from_dict(): - await test_list_monitored_resource_descriptors_async(request_type=dict) - - def test_list_monitored_resource_descriptors_pager(transport_name: str = "grpc"): client = LoggingServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2798,8 +2822,8 @@ async def test_list_monitored_resource_descriptors_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging.ListLogsRequest, - dict, + logging.ListLogsRequest({}), + {}, ], ) def test_list_logs(request_type, transport: str = "grpc"): @@ -2810,7 +2834,7 @@ def test_list_logs(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_logs), "__call__") as call: @@ -2857,10 +2881,11 @@ def test_list_logs_non_empty_request_with_auto_populated_field(): client.list_logs(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging.ListLogsRequest( + request_msg = logging.ListLogsRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_logs_use_cached_wrapped_rpc(): @@ -2939,9 +2964,14 @@ async def test_list_logs_async_use_cached_wrapped_rpc(transport: str = "grpc_asy @pytest.mark.asyncio -async def test_list_logs_async( - transport: str = "grpc_asyncio", request_type=logging.ListLogsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging.ListLogsRequest({}), + {}, + ], +) +async def test_list_logs_async(request_type, transport: str = "grpc_asyncio"): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2949,7 +2979,7 @@ async def test_list_logs_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_logs), "__call__") as call: @@ -2974,11 +3004,6 @@ async def test_list_logs_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_logs_async_from_dict(): - await test_list_logs_async(request_type=dict) - - def test_list_logs_field_headers(): client = LoggingServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -3315,8 +3340,8 @@ async def test_list_logs_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging.TailLogEntriesRequest, - dict, + logging.TailLogEntriesRequest({}), + {}, ], ) def test_tail_log_entries(request_type, transport: str = "grpc"): @@ -3327,7 +3352,7 @@ def test_tail_log_entries(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type requests = [request] # Mock the actual call within the gRPC stub, and fake the request. @@ -3426,9 +3451,14 @@ async def test_tail_log_entries_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_tail_log_entries_async( - transport: str = "grpc_asyncio", request_type=logging.TailLogEntriesRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging.TailLogEntriesRequest({}), + {}, + ], +) +async def test_tail_log_entries_async(request_type, transport: str = "grpc_asyncio"): client = LoggingServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3436,7 +3466,7 @@ async def test_tail_log_entries_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type requests = [request] # Mock the actual call within the gRPC stub, and fake the request. @@ -3458,11 +3488,6 @@ async def test_tail_log_entries_async( assert isinstance(message, logging.TailLogEntriesResponse) -@pytest.mark.asyncio -async def test_tail_log_entries_async_from_dict(): - await test_tail_log_entries_async(request_type=dict) - - def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.LoggingServiceV2GrpcTransport( @@ -3585,7 +3610,6 @@ def test_delete_log_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.DeleteLogRequest() - assert args[0] == request_msg @@ -3608,7 +3632,6 @@ def test_write_log_entries_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.WriteLogEntriesRequest() - assert args[0] == request_msg @@ -3629,7 +3652,6 @@ def test_list_log_entries_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListLogEntriesRequest() - assert args[0] == request_msg @@ -3652,7 +3674,6 @@ def test_list_monitored_resource_descriptors_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListMonitoredResourceDescriptorsRequest() - assert args[0] == request_msg @@ -3673,7 +3694,6 @@ def test_list_logs_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListLogsRequest() - assert args[0] == request_msg @@ -3710,7 +3730,6 @@ async def test_delete_log_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.DeleteLogRequest() - assert args[0] == request_msg @@ -3737,7 +3756,6 @@ async def test_write_log_entries_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.WriteLogEntriesRequest() - assert args[0] == request_msg @@ -3764,7 +3782,6 @@ async def test_list_log_entries_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListLogEntriesRequest() - assert args[0] == request_msg @@ -3793,7 +3810,6 @@ async def test_list_monitored_resource_descriptors_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListMonitoredResourceDescriptorsRequest() - assert args[0] == request_msg @@ -3821,7 +3837,6 @@ async def test_list_logs_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging.ListLogsRequest() - assert args[0] == request_msg diff --git a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py index 51904674ac2a..fe21c624a419 100644 --- a/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py +++ b/packages/google-cloud-logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import asyncio import json import math import os @@ -69,6 +70,9 @@ "principal": "service-account@example.com", } CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) +_UUID4_RE = re.compile( + r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" +) async def mock_async_gen(data, chunk_size=1): @@ -111,6 +115,21 @@ def modify_default_endpoint_template(client): ) +@pytest.fixture(autouse=True) +def set_event_loop(): + try: + asyncio.get_running_loop() + yield + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + yield + finally: + loop.close() + asyncio.set_event_loop(None) + + def test__get_default_mtls_endpoint(): api_endpoint = "example.googleapis.com" api_mtls_endpoint = "example.mtls.googleapis.com" @@ -1318,8 +1337,8 @@ def test_metrics_service_v2_client_create_channel_credentials_file( @pytest.mark.parametrize( "request_type", [ - logging_metrics.ListLogMetricsRequest, - dict, + logging_metrics.ListLogMetricsRequest({}), + {}, ], ) def test_list_log_metrics(request_type, transport: str = "grpc"): @@ -1330,7 +1349,7 @@ def test_list_log_metrics(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_log_metrics), "__call__") as call: @@ -1375,10 +1394,11 @@ def test_list_log_metrics_non_empty_request_with_auto_populated_field(): client.list_log_metrics(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_metrics.ListLogMetricsRequest( + request_msg = logging_metrics.ListLogMetricsRequest( parent="parent_value", page_token="page_token_value", ) + assert args[0] == request_msg def test_list_log_metrics_use_cached_wrapped_rpc(): @@ -1461,9 +1481,14 @@ async def test_list_log_metrics_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_list_log_metrics_async( - transport: str = "grpc_asyncio", request_type=logging_metrics.ListLogMetricsRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_metrics.ListLogMetricsRequest({}), + {}, + ], +) +async def test_list_log_metrics_async(request_type, transport: str = "grpc_asyncio"): client = MetricsServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1471,7 +1496,7 @@ async def test_list_log_metrics_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_log_metrics), "__call__") as call: @@ -1494,11 +1519,6 @@ async def test_list_log_metrics_async( assert response.next_page_token == "next_page_token_value" -@pytest.mark.asyncio -async def test_list_log_metrics_async_from_dict(): - await test_list_log_metrics_async(request_type=dict) - - def test_list_log_metrics_field_headers(): client = MetricsServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -1835,8 +1855,8 @@ async def test_list_log_metrics_async_pages(): @pytest.mark.parametrize( "request_type", [ - logging_metrics.GetLogMetricRequest, - dict, + logging_metrics.GetLogMetricRequest({}), + {}, ], ) def test_get_log_metric(request_type, transport: str = "grpc"): @@ -1847,7 +1867,7 @@ def test_get_log_metric(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_log_metric), "__call__") as call: @@ -1903,9 +1923,10 @@ def test_get_log_metric_non_empty_request_with_auto_populated_field(): client.get_log_metric(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_metrics.GetLogMetricRequest( + request_msg = logging_metrics.GetLogMetricRequest( metric_name="metric_name_value", ) + assert args[0] == request_msg def test_get_log_metric_use_cached_wrapped_rpc(): @@ -1986,9 +2007,14 @@ async def test_get_log_metric_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_get_log_metric_async( - transport: str = "grpc_asyncio", request_type=logging_metrics.GetLogMetricRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_metrics.GetLogMetricRequest({}), + {}, + ], +) +async def test_get_log_metric_async(request_type, transport: str = "grpc_asyncio"): client = MetricsServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -1996,7 +2022,7 @@ async def test_get_log_metric_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_log_metric), "__call__") as call: @@ -2031,11 +2057,6 @@ async def test_get_log_metric_async( assert response.version == logging_metrics.LogMetric.ApiVersion.V1 -@pytest.mark.asyncio -async def test_get_log_metric_async_from_dict(): - await test_get_log_metric_async(request_type=dict) - - def test_get_log_metric_field_headers(): client = MetricsServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2182,8 +2203,8 @@ async def test_get_log_metric_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_metrics.CreateLogMetricRequest, - dict, + logging_metrics.CreateLogMetricRequest({}), + {}, ], ) def test_create_log_metric(request_type, transport: str = "grpc"): @@ -2194,7 +2215,7 @@ def test_create_log_metric(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2254,9 +2275,10 @@ def test_create_log_metric_non_empty_request_with_auto_populated_field(): client.create_log_metric(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_metrics.CreateLogMetricRequest( + request_msg = logging_metrics.CreateLogMetricRequest( parent="parent_value", ) + assert args[0] == request_msg def test_create_log_metric_use_cached_wrapped_rpc(): @@ -2339,9 +2361,14 @@ async def test_create_log_metric_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_create_log_metric_async( - transport: str = "grpc_asyncio", request_type=logging_metrics.CreateLogMetricRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_metrics.CreateLogMetricRequest({}), + {}, + ], +) +async def test_create_log_metric_async(request_type, transport: str = "grpc_asyncio"): client = MetricsServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2349,7 +2376,7 @@ async def test_create_log_metric_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2386,11 +2413,6 @@ async def test_create_log_metric_async( assert response.version == logging_metrics.LogMetric.ApiVersion.V1 -@pytest.mark.asyncio -async def test_create_log_metric_async_from_dict(): - await test_create_log_metric_async(request_type=dict) - - def test_create_log_metric_field_headers(): client = MetricsServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2555,8 +2577,8 @@ async def test_create_log_metric_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_metrics.UpdateLogMetricRequest, - dict, + logging_metrics.UpdateLogMetricRequest({}), + {}, ], ) def test_update_log_metric(request_type, transport: str = "grpc"): @@ -2567,7 +2589,7 @@ def test_update_log_metric(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2627,9 +2649,10 @@ def test_update_log_metric_non_empty_request_with_auto_populated_field(): client.update_log_metric(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_metrics.UpdateLogMetricRequest( + request_msg = logging_metrics.UpdateLogMetricRequest( metric_name="metric_name_value", ) + assert args[0] == request_msg def test_update_log_metric_use_cached_wrapped_rpc(): @@ -2712,9 +2735,14 @@ async def test_update_log_metric_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_update_log_metric_async( - transport: str = "grpc_asyncio", request_type=logging_metrics.UpdateLogMetricRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_metrics.UpdateLogMetricRequest({}), + {}, + ], +) +async def test_update_log_metric_async(request_type, transport: str = "grpc_asyncio"): client = MetricsServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -2722,7 +2750,7 @@ async def test_update_log_metric_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2759,11 +2787,6 @@ async def test_update_log_metric_async( assert response.version == logging_metrics.LogMetric.ApiVersion.V1 -@pytest.mark.asyncio -async def test_update_log_metric_async_from_dict(): - await test_update_log_metric_async(request_type=dict) - - def test_update_log_metric_field_headers(): client = MetricsServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -2928,8 +2951,8 @@ async def test_update_log_metric_flattened_error_async(): @pytest.mark.parametrize( "request_type", [ - logging_metrics.DeleteLogMetricRequest, - dict, + logging_metrics.DeleteLogMetricRequest({}), + {}, ], ) def test_delete_log_metric(request_type, transport: str = "grpc"): @@ -2940,7 +2963,7 @@ def test_delete_log_metric(request_type, transport: str = "grpc"): # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2985,9 +3008,10 @@ def test_delete_log_metric_non_empty_request_with_auto_populated_field(): client.delete_log_metric(request=request) call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == logging_metrics.DeleteLogMetricRequest( + request_msg = logging_metrics.DeleteLogMetricRequest( metric_name="metric_name_value", ) + assert args[0] == request_msg def test_delete_log_metric_use_cached_wrapped_rpc(): @@ -3070,9 +3094,14 @@ async def test_delete_log_metric_async_use_cached_wrapped_rpc( @pytest.mark.asyncio -async def test_delete_log_metric_async( - transport: str = "grpc_asyncio", request_type=logging_metrics.DeleteLogMetricRequest -): +@pytest.mark.parametrize( + "request_type", + [ + logging_metrics.DeleteLogMetricRequest({}), + {}, + ], +) +async def test_delete_log_metric_async(request_type, transport: str = "grpc_asyncio"): client = MetricsServiceV2AsyncClient( credentials=async_anonymous_credentials(), transport=transport, @@ -3080,7 +3109,7 @@ async def test_delete_log_metric_async( # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = request_type() + request = request_type # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3100,11 +3129,6 @@ async def test_delete_log_metric_async( assert response is None -@pytest.mark.asyncio -async def test_delete_log_metric_async_from_dict(): - await test_delete_log_metric_async(request_type=dict) - - def test_delete_log_metric_field_headers(): client = MetricsServiceV2Client( credentials=ga_credentials.AnonymousCredentials(), @@ -3374,7 +3398,6 @@ def test_list_log_metrics_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.ListLogMetricsRequest() - assert args[0] == request_msg @@ -3395,7 +3418,6 @@ def test_get_log_metric_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.GetLogMetricRequest() - assert args[0] == request_msg @@ -3418,7 +3440,6 @@ def test_create_log_metric_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.CreateLogMetricRequest() - assert args[0] == request_msg @@ -3441,7 +3462,6 @@ def test_update_log_metric_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.UpdateLogMetricRequest() - assert args[0] == request_msg @@ -3464,7 +3484,6 @@ def test_delete_log_metric_empty_call_grpc(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.DeleteLogMetricRequest() - assert args[0] == request_msg @@ -3505,7 +3524,6 @@ async def test_list_log_metrics_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.ListLogMetricsRequest() - assert args[0] == request_msg @@ -3538,7 +3556,6 @@ async def test_get_log_metric_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.GetLogMetricRequest() - assert args[0] == request_msg @@ -3573,7 +3590,6 @@ async def test_create_log_metric_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.CreateLogMetricRequest() - assert args[0] == request_msg @@ -3608,7 +3624,6 @@ async def test_update_log_metric_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.UpdateLogMetricRequest() - assert args[0] == request_msg @@ -3633,7 +3648,6 @@ async def test_delete_log_metric_empty_call_grpc_asyncio(): call.assert_called() _, args, _ = call.mock_calls[0] request_msg = logging_metrics.DeleteLogMetricRequest() - assert args[0] == request_msg