Skip to content

Commit

Permalink
chore: use gapic-generator-python 0.58.4 (#165)
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 d4f27e5 commit 9db47b9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 47 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

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

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ def test_trace_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,
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_trace_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
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_trace_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,
Expand Down Expand Up @@ -434,7 +434,7 @@ def test_trace_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",
Expand Down Expand Up @@ -465,7 +465,8 @@ def test_trace_service_client_client_options_from_dict():
)


def test_list_traces(transport: str = "grpc", request_type=trace.ListTracesRequest):
@pytest.mark.parametrize("request_type", [trace.ListTracesRequest, dict,])
def test_list_traces(request_type, transport: str = "grpc"):
client = TraceServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -492,10 +493,6 @@ def test_list_traces(transport: str = "grpc", request_type=trace.ListTracesReque
assert response.next_page_token == "next_page_token_value"


def test_list_traces_from_dict():
test_list_traces(request_type=dict)


def test_list_traces_empty_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 @@ -614,8 +611,10 @@ async def test_list_traces_flattened_error_async():
)


def test_list_traces_pager():
client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_traces_pager(transport_name: str = "grpc"):
client = TraceServiceClient(
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_traces), "__call__") as call:
Expand All @@ -641,8 +640,10 @@ def test_list_traces_pager():
assert all(isinstance(i, trace.Trace) for i in results)


def test_list_traces_pages():
client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_traces_pages(transport_name: str = "grpc"):
client = TraceServiceClient(
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_traces), "__call__") as call:
Expand Down Expand Up @@ -717,7 +718,8 @@ async def test_list_traces_async_pages():
assert page_.raw_page.next_page_token == token


def test_get_trace(transport: str = "grpc", request_type=trace.GetTraceRequest):
@pytest.mark.parametrize("request_type", [trace.GetTraceRequest, dict,])
def test_get_trace(request_type, transport: str = "grpc"):
client = TraceServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -745,10 +747,6 @@ def test_get_trace(transport: str = "grpc", request_type=trace.GetTraceRequest):
assert response.trace_id == "trace_id_value"


def test_get_trace_from_dict():
test_get_trace(request_type=dict)


def test_get_trace_empty_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 @@ -880,7 +878,8 @@ async def test_get_trace_flattened_error_async():
)


def test_patch_traces(transport: str = "grpc", request_type=trace.PatchTracesRequest):
@pytest.mark.parametrize("request_type", [trace.PatchTracesRequest, dict,])
def test_patch_traces(request_type, transport: str = "grpc"):
client = TraceServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -904,10 +903,6 @@ def test_patch_traces(transport: str = "grpc", request_type=trace.PatchTracesReq
assert response is None


def test_patch_traces_from_dict():
test_patch_traces(request_type=dict)


def test_patch_traces_empty_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 @@ -1534,7 +1529,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
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,20 @@ def test_trace_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,
Expand Down Expand Up @@ -311,7 +311,7 @@ def test_trace_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
Expand Down Expand Up @@ -406,7 +406,7 @@ def test_trace_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,
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_trace_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",
Expand Down Expand Up @@ -468,9 +468,8 @@ def test_trace_service_client_client_options_from_dict():
)


def test_batch_write_spans(
transport: str = "grpc", request_type=tracing.BatchWriteSpansRequest
):
@pytest.mark.parametrize("request_type", [tracing.BatchWriteSpansRequest, dict,])
def test_batch_write_spans(request_type, transport: str = "grpc"):
client = TraceServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -496,10 +495,6 @@ def test_batch_write_spans(
assert response is None


def test_batch_write_spans_from_dict():
test_batch_write_spans(request_type=dict)


def test_batch_write_spans_empty_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 @@ -688,7 +683,8 @@ async def test_batch_write_spans_flattened_error_async():
)


def test_create_span(transport: str = "grpc", request_type=trace.Span):
@pytest.mark.parametrize("request_type", [trace.Span, dict,])
def test_create_span(request_type, transport: str = "grpc"):
client = TraceServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -721,10 +717,6 @@ def test_create_span(transport: str = "grpc", request_type=trace.Span):
assert response.span_kind == trace.Span.SpanKind.INTERNAL


def test_create_span_from_dict():
test_create_span(request_type=dict)


def test_create_span_empty_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 @@ -1348,7 +1340,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

0 comments on commit 9db47b9

Please sign in to comment.