From 5856799844fc8b43ebe8fdc7d71ae0000e7125b6 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:49:17 -0500 Subject: [PATCH] fix: rename mapping attribute of AudioStream to mapping_ (#121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: resolve issue where mapping attribute of AudioStream could not be set fix(deps): require proto-plus >= 1.20.1 * chore: use gapic-generator-python 0.58.4 committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(deps): require proto-plus >= 1.20.1 * ensure proto-plus>=1.20.1 is used for testing Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Dov Shlachter <dovs@google.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> --- .../transcoder_service/transports/base.py | 1 - .../video/transcoder_v1/types/resources.py | 8 +- .../transcoder_service/transports/base.py | 1 - .../transcoder_v1beta1/types/resources.py | 8 +- .../create_job_with_embedded_captions.py | 31 ++---- .../create_job_with_standalone_captions.py | 27 ++--- .../samples/snippets/job_test.py | 24 ++--- .../samples/snippets/requirements-test.txt | 1 + .../google-cloud-video-transcoder/setup.py | 6 +- .../testing/constraints-3.6.txt | 2 +- .../transcoder_v1/test_transcoder_service.py | 102 +++++++----------- .../test_transcoder_service.py | 102 +++++++----------- 12 files changed, 115 insertions(+), 198 deletions(-) diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py index 9c9f3cff5130..85cff1e74628 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py @@ -103,7 +103,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/types/resources.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/types/resources.py index cb02c1a96196..310852675f07 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/types/resources.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1/types/resources.py @@ -1345,7 +1345,7 @@ class AudioStream(proto.Message): - ``sr`` - Side right channel - ``fc`` - Front center channel - ``lfe`` - Low frequency - mapping (Sequence[google.cloud.video.transcoder_v1.types.AudioStream.AudioMapping]): + mapping_ (Sequence[google.cloud.video.transcoder_v1.types.AudioStream.AudioMapping]): The mapping for the ``Job.edit_list`` atoms with audio ``EditAtom.inputs``. sample_rate_hertz (int): @@ -1389,7 +1389,7 @@ class AudioMapping(proto.Message): bitrate_bps = proto.Field(proto.INT32, number=2,) channel_count = proto.Field(proto.INT32, number=3,) channel_layout = proto.RepeatedField(proto.STRING, number=4,) - mapping = proto.RepeatedField(proto.MESSAGE, number=5, message=AudioMapping,) + mapping_ = proto.RepeatedField(proto.MESSAGE, number=5, message=AudioMapping,) sample_rate_hertz = proto.Field(proto.INT32, number=6,) @@ -1408,7 +1408,7 @@ class TextStream(proto.Message): - ``cea608`` - ``cea708`` - ``webvtt`` - mapping (Sequence[google.cloud.video.transcoder_v1.types.TextStream.TextMapping]): + mapping_ (Sequence[google.cloud.video.transcoder_v1.types.TextStream.TextMapping]): The mapping for the ``Job.edit_list`` atoms with text ``EditAtom.inputs``. """ @@ -1433,7 +1433,7 @@ class TextMapping(proto.Message): input_track = proto.Field(proto.INT32, number=3,) codec = proto.Field(proto.STRING, number=1,) - mapping = proto.RepeatedField(proto.MESSAGE, number=3, message=TextMapping,) + mapping_ = proto.RepeatedField(proto.MESSAGE, number=3, message=TextMapping,) class SegmentSettings(proto.Message): diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py index 7a9c09285bc8..4f2167b74e9b 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py @@ -103,7 +103,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py index 7c7a7f847b9c..41ac5c7cda07 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py @@ -1093,7 +1093,7 @@ class AudioStream(proto.Message): - 'sr' - Side right channel - 'fc' - Front center channel - 'lfe' - Low frequency - mapping (Sequence[google.cloud.video.transcoder_v1beta1.types.AudioStream.AudioAtom]): + mapping_ (Sequence[google.cloud.video.transcoder_v1beta1.types.AudioStream.AudioAtom]): The mapping for the ``Job.edit_list`` atoms with audio ``EditAtom.inputs``. sample_rate_hertz (int): @@ -1161,7 +1161,7 @@ class AudioChannelInput(proto.Message): bitrate_bps = proto.Field(proto.INT32, number=2,) channel_count = proto.Field(proto.INT32, number=3,) channel_layout = proto.RepeatedField(proto.STRING, number=4,) - mapping = proto.RepeatedField(proto.MESSAGE, number=5, message=AudioAtom,) + mapping_ = proto.RepeatedField(proto.MESSAGE, number=5, message=AudioAtom,) sample_rate_hertz = proto.Field(proto.INT32, number=6,) @@ -1184,7 +1184,7 @@ class TextStream(proto.Message): Required. The BCP-47 language code, such as ``"en-US"`` or ``"sr-Latn"``. For more information, see https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - mapping (Sequence[google.cloud.video.transcoder_v1beta1.types.TextStream.TextAtom]): + mapping_ (Sequence[google.cloud.video.transcoder_v1beta1.types.TextStream.TextAtom]): The mapping for the ``Job.edit_list`` atoms with text ``EditAtom.inputs``. """ @@ -1223,7 +1223,7 @@ class TextInput(proto.Message): codec = proto.Field(proto.STRING, number=1,) language_code = proto.Field(proto.STRING, number=2,) - mapping = proto.RepeatedField(proto.MESSAGE, number=3, message=TextAtom,) + mapping_ = proto.RepeatedField(proto.MESSAGE, number=3, message=TextAtom,) class SegmentSettings(proto.Message): diff --git a/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_embedded_captions.py b/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_embedded_captions.py index 31e4216ce9b0..a81e66888181 100644 --- a/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_embedded_captions.py +++ b/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_embedded_captions.py @@ -32,11 +32,7 @@ def create_job_with_embedded_captions( - project_id, - location, - input_video_uri, - input_captions_uri, - output_uri, + project_id, location, input_video_uri, input_captions_uri, output_uri, ): """Creates a job based on an ad-hoc job configuration that embeds captions in the output video. @@ -57,19 +53,12 @@ def create_job_with_embedded_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input( - key="input0", - uri=input_video_uri, - ), - transcoder_v1.types.Input( - key="caption-input0", - uri=input_captions_uri, - ), + transcoder_v1.types.Input(key="input0", uri=input_video_uri,), + transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", - inputs=["input0", "caption-input0"], + key="atom0", inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -131,9 +120,7 @@ def create_job_with_embedded_captions( elementary_streams=["video-stream0", "audio-stream0"], ), transcoder_v1.types.MuxStream( - key="sd-dash", - container="fmp4", - elementary_streams=["video-stream0"], + key="sd-dash", container="fmp4", elementary_streams=["video-stream0"], ), transcoder_v1.types.MuxStream( key="audio-dash", @@ -143,9 +130,7 @@ def create_job_with_embedded_captions( ], manifests=[ transcoder_v1.types.Manifest( - file_name="manifest.m3u8", - type_="HLS", - mux_streams=["sd-hls"], + file_name="manifest.m3u8", type_="HLS", mux_streams=["sd-hls"], ), transcoder_v1.types.Manifest( file_name="manifest.mpd", @@ -165,9 +150,7 @@ def create_job_with_embedded_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", - help="The location to start this job in.", - default="us-central1", + "--location", help="The location to start this job in.", default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_standalone_captions.py b/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_standalone_captions.py index 5ed546763c9f..de32f49b176f 100644 --- a/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_standalone_captions.py +++ b/packages/google-cloud-video-transcoder/samples/snippets/create_job_with_standalone_captions.py @@ -33,11 +33,7 @@ def create_job_with_standalone_captions( - project_id, - location, - input_video_uri, - input_captions_uri, - output_uri, + project_id, location, input_video_uri, input_captions_uri, output_uri, ): """Creates a job based on an ad-hoc job configuration that can use captions from a standalone file. @@ -58,19 +54,12 @@ def create_job_with_standalone_captions( job.output_uri = output_uri job.config = transcoder_v1.types.JobConfig( inputs=[ - transcoder_v1.types.Input( - key="input0", - uri=input_video_uri, - ), - transcoder_v1.types.Input( - key="caption-input0", - uri=input_captions_uri, - ), + transcoder_v1.types.Input(key="input0", uri=input_video_uri,), + transcoder_v1.types.Input(key="caption-input0", uri=input_captions_uri,), ], edit_list=[ transcoder_v1.types.EditAtom( - key="atom0", - inputs=["input0", "caption-input0"], + key="atom0", inputs=["input0", "caption-input0"], ), ], elementary_streams=[ @@ -136,9 +125,7 @@ def create_job_with_standalone_captions( container="vtt", elementary_streams=["vtt-stream0"], segment_settings=transcoder_v1.types.SegmentSettings( - segment_duration=duration.Duration( - seconds=6, - ), + segment_duration=duration.Duration(seconds=6,), individual_segments=True, ), ), @@ -162,9 +149,7 @@ def create_job_with_standalone_captions( parser = argparse.ArgumentParser() parser.add_argument("--project_id", help="Your Cloud project ID.", required=True) parser.add_argument( - "--location", - help="The location to start this job in.", - default="us-central1", + "--location", help="The location to start this job in.", default="us-central1", ) parser.add_argument( "--input_video_uri", diff --git a/packages/google-cloud-video-transcoder/samples/snippets/job_test.py b/packages/google-cloud-video-transcoder/samples/snippets/job_test.py index fa9a93e0f89c..d924472c858d 100644 --- a/packages/google-cloud-video-transcoder/samples/snippets/job_test.py +++ b/packages/google-cloud-video-transcoder/samples/snippets/job_test.py @@ -63,8 +63,12 @@ output_uri_for_animated_overlay = ( f"gs://{output_bucket_name}/test-output-animated-overlay/" ) -output_uri_for_embedded_captions = f"gs://{output_bucket_name}/test-output-embedded-captions/" -output_uri_for_standalone_captions = f"gs://{output_bucket_name}/test-output-standalone-captions/" +output_uri_for_embedded_captions = ( + f"gs://{output_bucket_name}/test-output-embedded-captions/" +) +output_uri_for_standalone_captions = ( + f"gs://{output_bucket_name}/test-output-standalone-captions/" +) small_spritesheet_file_prefix = "small-sprite-sheet" large_spritesheet_file_prefix = "large-sprite-sheet" @@ -267,10 +271,7 @@ def test_create_job_with_animated_overlay(capsys, test_bucket): def test_create_job_with_set_number_spritesheet(capsys, test_bucket): create_job_with_set_number_images_spritesheet.create_job_with_set_number_images_spritesheet( - project_id, - location, - input_uri, - output_uri_for_set_number_spritesheet, + project_id, location, input_uri, output_uri_for_set_number_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -318,10 +319,7 @@ def test_create_job_with_set_number_spritesheet(capsys, test_bucket): def test_create_job_with_periodic_spritesheet(capsys, test_bucket): create_job_with_periodic_images_spritesheet.create_job_with_periodic_images_spritesheet( - project_id, - location, - input_uri, - output_uri_for_periodic_spritesheet, + project_id, location, input_uri, output_uri_for_periodic_spritesheet, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" @@ -409,11 +407,7 @@ def test_create_job_with_concatenated_inputs(capsys, test_bucket): def test_create_job_with_embedded_captions(capsys, test_bucket): create_job_with_embedded_captions.create_job_with_embedded_captions( - project_id, - location, - input_uri, - captions_uri, - output_uri_for_embedded_captions, + project_id, location, input_uri, captions_uri, output_uri_for_embedded_captions, ) out, _ = capsys.readouterr() job_name_prefix = f"projects/{project_number}/locations/{location}/jobs/" diff --git a/packages/google-cloud-video-transcoder/samples/snippets/requirements-test.txt b/packages/google-cloud-video-transcoder/samples/snippets/requirements-test.txt index 52c66823c1a1..2996534ce7ab 100644 --- a/packages/google-cloud-video-transcoder/samples/snippets/requirements-test.txt +++ b/packages/google-cloud-video-transcoder/samples/snippets/requirements-test.txt @@ -1,3 +1,4 @@ backoff==1.11.1 google-cloud-storage==1.43.0 pytest==6.2.4 +proto-plus>=1.20.1 diff --git a/packages/google-cloud-video-transcoder/setup.py b/packages/google-cloud-video-transcoder/setup.py index 0a4dfc17f8aa..febe200c32d1 100644 --- a/packages/google-cloud-video-transcoder/setup.py +++ b/packages/google-cloud-video-transcoder/setup.py @@ -45,7 +45,11 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.28.0, <3.0.0dev", - "proto-plus >= 1.4.0", + # Require proto-plus >= 1.20.1 which includes + # a fix to mitigate collisions in field names, specifically + # the `mapping` term which is a reserved term in proto-plus. + # https://github.com/googleapis/proto-plus-python/pull/295 + "proto-plus >= 1.20.1", ), python_requires=">=3.6", classifiers=[ diff --git a/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt b/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt index 6b451bc37e2f..f12a92252146 100644 --- a/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt +++ b/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt @@ -6,4 +6,4 @@ # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 google-api-core==1.28.0 -proto-plus==1.4.0 +proto-plus==1.20.1 diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py index ef49f5132be8..5b90a117f2d7 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1/test_transcoder_service.py @@ -256,20 +256,20 @@ def test_transcoder_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -338,7 +338,7 @@ def test_transcoder_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -433,7 +433,7 @@ def test_transcoder_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -464,7 +464,7 @@ def test_transcoder_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -497,7 +497,8 @@ def test_transcoder_service_client_client_options_from_dict(): ) -def test_create_job(transport: str = "grpc", request_type=services.CreateJobRequest): +@pytest.mark.parametrize("request_type", [services.CreateJobRequest, dict,]) +def test_create_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -533,10 +534,6 @@ def test_create_job(transport: str = "grpc", request_type=services.CreateJobRequ assert response.ttl_after_completion_days == 2670 -def test_create_job_from_dict(): - test_create_job(request_type=dict) - - def test_create_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -732,7 +729,8 @@ async def test_create_job_flattened_error_async(): ) -def test_list_jobs(transport: str = "grpc", request_type=services.ListJobsRequest): +@pytest.mark.parametrize("request_type", [services.ListJobsRequest, dict,]) +def test_list_jobs(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -760,10 +758,6 @@ def test_list_jobs(transport: str = "grpc", request_type=services.ListJobsReques assert response.unreachable == ["unreachable_value"] -def test_list_jobs_from_dict(): - test_list_jobs(request_type=dict) - - def test_list_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -943,8 +937,10 @@ async def test_list_jobs_flattened_error_async(): ) -def test_list_jobs_pager(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_jobs_pager(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: @@ -973,8 +969,10 @@ def test_list_jobs_pager(): assert all(isinstance(i, resources.Job) for i in results) -def test_list_jobs_pages(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_jobs_pages(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: @@ -1053,7 +1051,8 @@ async def test_list_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_job(transport: str = "grpc", request_type=services.GetJobRequest): +@pytest.mark.parametrize("request_type", [services.GetJobRequest, dict,]) +def test_get_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1089,10 +1088,6 @@ def test_get_job(transport: str = "grpc", request_type=services.GetJobRequest): assert response.ttl_after_completion_days == 2670 -def test_get_job_from_dict(): - test_get_job(request_type=dict) - - def test_get_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1274,7 +1269,8 @@ async def test_get_job_flattened_error_async(): ) -def test_delete_job(transport: str = "grpc", request_type=services.DeleteJobRequest): +@pytest.mark.parametrize("request_type", [services.DeleteJobRequest, dict,]) +def test_delete_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1298,10 +1294,6 @@ def test_delete_job(transport: str = "grpc", request_type=services.DeleteJobRequ assert response is None -def test_delete_job_from_dict(): - test_delete_job(request_type=dict) - - def test_delete_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1470,9 +1462,8 @@ async def test_delete_job_flattened_error_async(): ) -def test_create_job_template( - transport: str = "grpc", request_type=services.CreateJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.CreateJobTemplateRequest, dict,]) +def test_create_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1499,10 +1490,6 @@ def test_create_job_template( assert response.name == "name_value" -def test_create_job_template_from_dict(): - test_create_job_template(request_type=dict) - - def test_create_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1716,9 +1703,8 @@ async def test_create_job_template_flattened_error_async(): ) -def test_list_job_templates( - transport: str = "grpc", request_type=services.ListJobTemplatesRequest -): +@pytest.mark.parametrize("request_type", [services.ListJobTemplatesRequest, dict,]) +def test_list_job_templates(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1748,10 +1734,6 @@ def test_list_job_templates( assert response.unreachable == ["unreachable_value"] -def test_list_job_templates_from_dict(): - test_list_job_templates(request_type=dict) - - def test_list_job_templates_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1943,8 +1925,10 @@ async def test_list_job_templates_flattened_error_async(): ) -def test_list_job_templates_pager(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_job_templates_pager(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1983,8 +1967,10 @@ def test_list_job_templates_pager(): assert all(isinstance(i, resources.JobTemplate) for i in results) -def test_list_job_templates_pages(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_job_templates_pages(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2093,9 +2079,8 @@ async def test_list_job_templates_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_job_template( - transport: str = "grpc", request_type=services.GetJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.GetJobTemplateRequest, dict,]) +def test_get_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2120,10 +2105,6 @@ def test_get_job_template( assert response.name == "name_value" -def test_get_job_template_from_dict(): - test_get_job_template(request_type=dict) - - def test_get_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2299,9 +2280,8 @@ async def test_get_job_template_flattened_error_async(): ) -def test_delete_job_template( - transport: str = "grpc", request_type=services.DeleteJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.DeleteJobTemplateRequest, dict,]) +def test_delete_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2327,10 +2307,6 @@ def test_delete_job_template( assert response is None -def test_delete_job_template_from_dict(): - test_delete_job_template(request_type=dict) - - def test_delete_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3056,7 +3032,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py index 364c2ef0abc4..da0875de3e5b 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py @@ -254,20 +254,20 @@ def test_transcoder_service_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -336,7 +336,7 @@ def test_transcoder_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -431,7 +431,7 @@ def test_transcoder_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -462,7 +462,7 @@ def test_transcoder_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -495,7 +495,8 @@ def test_transcoder_service_client_client_options_from_dict(): ) -def test_create_job(transport: str = "grpc", request_type=services.CreateJobRequest): +@pytest.mark.parametrize("request_type", [services.CreateJobRequest, dict,]) +def test_create_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -535,10 +536,6 @@ def test_create_job(transport: str = "grpc", request_type=services.CreateJobRequ assert response.ttl_after_completion_days == 2670 -def test_create_job_from_dict(): - test_create_job(request_type=dict) - - def test_create_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -738,7 +735,8 @@ async def test_create_job_flattened_error_async(): ) -def test_list_jobs(transport: str = "grpc", request_type=services.ListJobsRequest): +@pytest.mark.parametrize("request_type", [services.ListJobsRequest, dict,]) +def test_list_jobs(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -765,10 +763,6 @@ def test_list_jobs(transport: str = "grpc", request_type=services.ListJobsReques assert response.next_page_token == "next_page_token_value" -def test_list_jobs_from_dict(): - test_list_jobs(request_type=dict) - - def test_list_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -944,8 +938,10 @@ async def test_list_jobs_flattened_error_async(): ) -def test_list_jobs_pager(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_jobs_pager(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: @@ -974,8 +970,10 @@ def test_list_jobs_pager(): assert all(isinstance(i, resources.Job) for i in results) -def test_list_jobs_pages(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_jobs_pages(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: @@ -1054,7 +1052,8 @@ async def test_list_jobs_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_job(transport: str = "grpc", request_type=services.GetJobRequest): +@pytest.mark.parametrize("request_type", [services.GetJobRequest, dict,]) +def test_get_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1094,10 +1093,6 @@ def test_get_job(transport: str = "grpc", request_type=services.GetJobRequest): assert response.ttl_after_completion_days == 2670 -def test_get_job_from_dict(): - test_get_job(request_type=dict) - - def test_get_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1283,7 +1278,8 @@ async def test_get_job_flattened_error_async(): ) -def test_delete_job(transport: str = "grpc", request_type=services.DeleteJobRequest): +@pytest.mark.parametrize("request_type", [services.DeleteJobRequest, dict,]) +def test_delete_job(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1307,10 +1303,6 @@ def test_delete_job(transport: str = "grpc", request_type=services.DeleteJobRequ assert response is None -def test_delete_job_from_dict(): - test_delete_job(request_type=dict) - - def test_delete_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1479,9 +1471,8 @@ async def test_delete_job_flattened_error_async(): ) -def test_create_job_template( - transport: str = "grpc", request_type=services.CreateJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.CreateJobTemplateRequest, dict,]) +def test_create_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1508,10 +1499,6 @@ def test_create_job_template( assert response.name == "name_value" -def test_create_job_template_from_dict(): - test_create_job_template(request_type=dict) - - def test_create_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1725,9 +1712,8 @@ async def test_create_job_template_flattened_error_async(): ) -def test_list_job_templates( - transport: str = "grpc", request_type=services.ListJobTemplatesRequest -): +@pytest.mark.parametrize("request_type", [services.ListJobTemplatesRequest, dict,]) +def test_list_job_templates(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1756,10 +1742,6 @@ def test_list_job_templates( assert response.next_page_token == "next_page_token_value" -def test_list_job_templates_from_dict(): - test_list_job_templates(request_type=dict) - - def test_list_job_templates_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1947,8 +1929,10 @@ async def test_list_job_templates_flattened_error_async(): ) -def test_list_job_templates_pager(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_job_templates_pager(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1987,8 +1971,10 @@ def test_list_job_templates_pager(): assert all(isinstance(i, resources.JobTemplate) for i in results) -def test_list_job_templates_pages(): - client = TranscoderServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_job_templates_pages(transport_name: str = "grpc"): + client = TranscoderServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2097,9 +2083,8 @@ async def test_list_job_templates_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_job_template( - transport: str = "grpc", request_type=services.GetJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.GetJobTemplateRequest, dict,]) +def test_get_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2124,10 +2109,6 @@ def test_get_job_template( assert response.name == "name_value" -def test_get_job_template_from_dict(): - test_get_job_template(request_type=dict) - - def test_get_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2303,9 +2284,8 @@ async def test_get_job_template_flattened_error_async(): ) -def test_delete_job_template( - transport: str = "grpc", request_type=services.DeleteJobTemplateRequest -): +@pytest.mark.parametrize("request_type", [services.DeleteJobTemplateRequest, dict,]) +def test_delete_job_template(request_type, transport: str = "grpc"): client = TranscoderServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2331,10 +2311,6 @@ def test_delete_job_template( assert response is None -def test_delete_job_template_from_dict(): - test_delete_job_template(request_type=dict) - - def test_delete_job_template_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3060,7 +3036,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object(