Skip to content

Commit

Permalink
chore: use gapic-generator-python 0.58.4 (#260)
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>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Jan 15, 2022
1 parent ed7d7dd commit 2492294
Show file tree
Hide file tree
Showing 15 changed files with 329 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

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

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ def transport(self) -> MetricServiceTransport:
return self._transport

'''@staticmethod
def metric_descriptor_path(project: str,) -> str:
def metric_descriptor_path(project: str,metric_descriptor: str,) -> str:
"""Returns a fully-qualified metric_descriptor string."""
return "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, )
return "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(project=project, metric_descriptor=metric_descriptor, )
@staticmethod
def parse_metric_descriptor_path(path: str) -> Dict[str,str]:
"""Parses a metric_descriptor path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/metricDescriptors/{metric_descriptor=**}$", path)
m = re.match(r"^projects/(?P<project>.+?)/metricDescriptors/(?P<metric_descriptor>.+?)$", path)
return m.groupdict() if m else {}'''

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,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 @@ -107,7 +107,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

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

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

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

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,20 @@ def test_alert_policy_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 @@ -342,7 +342,7 @@ def test_alert_policy_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 @@ -437,7 +437,7 @@ def test_alert_policy_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 @@ -468,7 +468,7 @@ def test_alert_policy_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 @@ -501,9 +501,10 @@ def test_alert_policy_service_client_client_options_from_dict():
)


def test_list_alert_policies(
transport: str = "grpc", request_type=alert_service.ListAlertPoliciesRequest
):
@pytest.mark.parametrize(
"request_type", [alert_service.ListAlertPoliciesRequest, dict,]
)
def test_list_alert_policies(request_type, transport: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -533,10 +534,6 @@ def test_list_alert_policies(
assert response.total_size == 1086


def test_list_alert_policies_from_dict():
test_list_alert_policies(request_type=dict)


def test_list_alert_policies_empty_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 @@ -733,8 +730,10 @@ async def test_list_alert_policies_flattened_error_async():
)


def test_list_alert_policies_pager():
client = AlertPolicyServiceClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_alert_policies_pager(transport_name: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -775,8 +774,10 @@ def test_list_alert_policies_pager():
assert all(isinstance(i, alert.AlertPolicy) for i in results)


def test_list_alert_policies_pages():
client = AlertPolicyServiceClient(credentials=ga_credentials.AnonymousCredentials,)
def test_list_alert_policies_pages(transport_name: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials, transport=transport_name,
)

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -891,9 +892,8 @@ async def test_list_alert_policies_async_pages():
assert page_.raw_page.next_page_token == token


def test_get_alert_policy(
transport: str = "grpc", request_type=alert_service.GetAlertPolicyRequest
):
@pytest.mark.parametrize("request_type", [alert_service.GetAlertPolicyRequest, dict,])
def test_get_alert_policy(request_type, transport: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -926,10 +926,6 @@ def test_get_alert_policy(
assert response.notification_channels == ["notification_channels_value"]


def test_get_alert_policy_from_dict():
test_get_alert_policy(request_type=dict)


def test_get_alert_policy_empty_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 @@ -1115,9 +1111,10 @@ async def test_get_alert_policy_flattened_error_async():
)


def test_create_alert_policy(
transport: str = "grpc", request_type=alert_service.CreateAlertPolicyRequest
):
@pytest.mark.parametrize(
"request_type", [alert_service.CreateAlertPolicyRequest, dict,]
)
def test_create_alert_policy(request_type, transport: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -1152,10 +1149,6 @@ def test_create_alert_policy(
assert response.notification_channels == ["notification_channels_value"]


def test_create_alert_policy_from_dict():
test_create_alert_policy(request_type=dict)


def test_create_alert_policy_empty_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 @@ -1367,9 +1360,10 @@ async def test_create_alert_policy_flattened_error_async():
)


def test_delete_alert_policy(
transport: str = "grpc", request_type=alert_service.DeleteAlertPolicyRequest
):
@pytest.mark.parametrize(
"request_type", [alert_service.DeleteAlertPolicyRequest, dict,]
)
def test_delete_alert_policy(request_type, transport: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -1395,10 +1389,6 @@ def test_delete_alert_policy(
assert response is None


def test_delete_alert_policy_from_dict():
test_delete_alert_policy(request_type=dict)


def test_delete_alert_policy_empty_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 @@ -1585,9 +1575,10 @@ async def test_delete_alert_policy_flattened_error_async():
)


def test_update_alert_policy(
transport: str = "grpc", request_type=alert_service.UpdateAlertPolicyRequest
):
@pytest.mark.parametrize(
"request_type", [alert_service.UpdateAlertPolicyRequest, dict,]
)
def test_update_alert_policy(request_type, transport: str = "grpc"):
client = AlertPolicyServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -1622,10 +1613,6 @@ def test_update_alert_policy(
assert response.notification_channels == ["notification_channels_value"]


def test_update_alert_policy_from_dict():
test_update_alert_policy(request_type=dict)


def test_update_alert_policy_empty_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 @@ -2407,7 +2394,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 2492294

Please sign in to comment.