Skip to content

Commit

Permalink
chore: use gapic-generator-python 0.58.4 (#297)
Browse files Browse the repository at this point in the history
* chore: use gapic-generator-python 0.58.4

fix: provide appropriate mock values for message body fields

committer: dovs
PiperOrigin-RevId: 419025932

Source-Link: googleapis/googleapis@73da669

Source-Link: googleapis/googleapis-gen@46df624
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Jan 8, 2022
1 parent d10cb17 commit 5d838f0
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ def test_speech_client_client_options(client_class, transport_class, transport_n
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -299,7 +299,7 @@ def test_speech_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
Expand Down Expand Up @@ -390,7 +390,7 @@ def test_speech_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,
Expand All @@ -417,7 +417,7 @@ def test_speech_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",
Expand Down Expand Up @@ -448,7 +448,8 @@ def test_speech_client_client_options_from_dict():
)


def test_recognize(transport: str = "grpc", request_type=cloud_speech.RecognizeRequest):
@pytest.mark.parametrize("request_type", [cloud_speech.RecognizeRequest, dict,])
def test_recognize(request_type, transport: str = "grpc"):
client = SpeechClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -472,10 +473,6 @@ def test_recognize(transport: str = "grpc", request_type=cloud_speech.RecognizeR
assert isinstance(response, cloud_speech.RecognizeResponse)


def test_recognize_from_dict():
test_recognize(request_type=dict)


def test_recognize_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -621,9 +618,10 @@ async def test_recognize_flattened_error_async():
)


def test_long_running_recognize(
transport: str = "grpc", request_type=cloud_speech.LongRunningRecognizeRequest
):
@pytest.mark.parametrize(
"request_type", [cloud_speech.LongRunningRecognizeRequest, dict,]
)
def test_long_running_recognize(request_type, transport: str = "grpc"):
client = SpeechClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -649,10 +647,6 @@ def test_long_running_recognize(
assert isinstance(response, future.Future)


def test_long_running_recognize_from_dict():
test_long_running_recognize(request_type=dict)


def test_long_running_recognize_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -807,9 +801,10 @@ async def test_long_running_recognize_flattened_error_async():
)


def test_streaming_recognize(
transport: str = "grpc", request_type=cloud_speech.StreamingRecognizeRequest
):
@pytest.mark.parametrize(
"request_type", [cloud_speech.StreamingRecognizeRequest, dict,]
)
def test_streaming_recognize(request_type, transport: str = "grpc"):
client = SpeechClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -837,10 +832,6 @@ def test_streaming_recognize(
assert isinstance(message, cloud_speech.StreamingRecognizeResponse)


def test_streaming_recognize_from_dict():
test_streaming_recognize(request_type=dict)


@pytest.mark.asyncio
async def test_streaming_recognize_async(
transport: str = "grpc_asyncio", request_type=cloud_speech.StreamingRecognizeRequest
Expand Down Expand Up @@ -1434,7 +1425,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(
Expand Down
Loading

0 comments on commit 5d838f0

Please sign in to comment.