Skip to content

Commit

Permalink
chore: Use gapic-generator-python 0.65.0 (#104)
Browse files Browse the repository at this point in the history
* chore: Use gapic-generator-python 0.65.0

PiperOrigin-RevId: 440970084

Source-Link: googleapis/googleapis@5e0a3d5

Source-Link: googleapis/googleapis-gen@b0c628a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBjNjI4YTNmYWRlNzY4ZjIyNWQ3Njk5Mjc5MWVhMWJhMmE4ODFiZSJ9

* 🦉 Updates from OwlBot post-processor

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 Apr 12, 2022
1 parent 7f4d86a commit ed2de3a
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import functools
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core.client_options import ClientOptions
Expand Down Expand Up @@ -216,7 +216,6 @@ async def list_connections(
r"""Lists connections that are currently active for the
given Apigee Connect endpoint.
.. code-block:: python
from google.cloud import apigeeconnect_v1
Expand Down Expand Up @@ -289,8 +288,7 @@ def sample_list_connections():
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.Unknown,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
import os
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core import client_options as client_options_lib
Expand Down Expand Up @@ -435,7 +435,6 @@ def list_connections(
r"""Lists connections that are currently active for the
given Apigee Connect endpoint.
.. code-block:: python
from google.cloud import apigeeconnect_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
"""

# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
Expand Down Expand Up @@ -127,8 +128,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.Unknown,
core_exceptions.GoogleAPICallError,
),
deadline=60.0,
),
Expand Down Expand Up @@ -158,5 +158,9 @@ def list_connections(
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()


__all__ = ("ConnectionServiceTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,9 @@ def list_connections(
def close(self):
self.grpc_channel.close()

@property
def kind(self) -> str:
return "grpc"


__all__ = ("ConnectionServiceGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import re
from typing import (
Dict,
Mapping,
Optional,
AsyncIterable,
Awaitable,
Expand Down Expand Up @@ -222,7 +223,6 @@ def egress(
The listener streams http requests and the dialer
streams http responses.
.. code-block:: python
from google.cloud import apigeeconnect_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
from collections import OrderedDict
import os
import re
from typing import Dict, Optional, Iterable, Iterator, Sequence, Tuple, Type, Union
from typing import (
Dict,
Mapping,
Optional,
Iterable,
Iterator,
Sequence,
Tuple,
Type,
Union,
)
import pkg_resources

from google.api_core import client_options as client_options_lib
Expand Down Expand Up @@ -424,7 +434,6 @@ def egress(
The listener streams http requests and the dialer
streams http responses.
.. code-block:: python
from google.cloud import apigeeconnect_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
be used for service account credentials.
"""

# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
Expand Down Expand Up @@ -145,5 +146,9 @@ def egress(
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()


__all__ = ("TetherTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,9 @@ def egress(self) -> Callable[[tether.EgressResponse], tether.EgressRequest]:
def close(self):
self.grpc_channel.close()

@property
def kind(self) -> str:
return "grpc"


__all__ = ("TetherGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,26 @@ def test__get_default_mtls_endpoint():


@pytest.mark.parametrize(
"client_class",
"client_class,transport_name",
[
ConnectionServiceClient,
ConnectionServiceAsyncClient,
(ConnectionServiceClient, "grpc"),
(ConnectionServiceAsyncClient, "grpc_asyncio"),
],
)
def test_connection_service_client_from_service_account_info(client_class):
def test_connection_service_client_from_service_account_info(
client_class, transport_name
):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_info"
) as factory:
factory.return_value = creds
info = {"valid": True}
client = client_class.from_service_account_info(info)
client = client_class.from_service_account_info(info, transport=transport_name)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

assert client.transport._host == "apigeeconnect.googleapis.com:443"
assert client.transport._host == ("apigeeconnect.googleapis.com:443")


@pytest.mark.parametrize(
Expand Down Expand Up @@ -136,27 +138,33 @@ def test_connection_service_client_service_account_always_use_jwt(


@pytest.mark.parametrize(
"client_class",
"client_class,transport_name",
[
ConnectionServiceClient,
ConnectionServiceAsyncClient,
(ConnectionServiceClient, "grpc"),
(ConnectionServiceAsyncClient, "grpc_asyncio"),
],
)
def test_connection_service_client_from_service_account_file(client_class):
def test_connection_service_client_from_service_account_file(
client_class, transport_name
):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_file"
) as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
client = client_class.from_service_account_file(
"dummy/file/path.json", transport=transport_name
)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

client = client_class.from_service_account_json("dummy/file/path.json")
client = client_class.from_service_account_json(
"dummy/file/path.json", transport=transport_name
)
assert client.transport._credentials == creds
assert isinstance(client, client_class)

assert client.transport._host == "apigeeconnect.googleapis.com:443"
assert client.transport._host == ("apigeeconnect.googleapis.com:443")


def test_connection_service_client_get_transport_class():
Expand Down Expand Up @@ -1022,7 +1030,7 @@ async def test_list_connections_async_pager():
)
assert async_pager.next_page_token == "abc"
responses = []
async for response in async_pager:
async for response in async_pager: # pragma: no branch
responses.append(response)

assert len(responses) == 6
Expand Down Expand Up @@ -1068,7 +1076,9 @@ async def test_list_connections_async_pages():
RuntimeError,
)
pages = []
async for page_ in (await client.list_connections(request={})).pages:
async for page_ in (
await client.list_connections(request={})
).pages: # pragma: no branch
pages.append(page_)
for page_, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page_.raw_page.next_page_token == token
Expand Down Expand Up @@ -1165,6 +1175,19 @@ def test_transport_adc(transport_class):
adc.assert_called_once()


@pytest.mark.parametrize(
"transport_name",
[
"grpc",
],
)
def test_transport_kind(transport_name):
transport = ConnectionServiceClient.get_transport_class(transport_name)(
credentials=ga_credentials.AnonymousCredentials(),
)
assert transport.kind == transport_name


def test_transport_grpc_default():
# A client should use the gRPC transport by default.
client = ConnectionServiceClient(
Expand Down Expand Up @@ -1205,6 +1228,14 @@ def test_connection_service_base_transport():
with pytest.raises(NotImplementedError):
transport.close()

# Catch all for all remaining methods and properties
remainder = [
"kind",
]
for r in remainder:
with pytest.raises(NotImplementedError):
getattr(transport, r)()


def test_connection_service_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
Expand Down Expand Up @@ -1350,24 +1381,40 @@ def test_connection_service_grpc_transport_client_cert_source_for_mtls(transport
)


def test_connection_service_host_no_port():
@pytest.mark.parametrize(
"transport_name",
[
"grpc",
"grpc_asyncio",
],
)
def test_connection_service_host_no_port(transport_name):
client = ConnectionServiceClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="apigeeconnect.googleapis.com"
),
transport=transport_name,
)
assert client.transport._host == "apigeeconnect.googleapis.com:443"
assert client.transport._host == ("apigeeconnect.googleapis.com:443")


def test_connection_service_host_with_port():
@pytest.mark.parametrize(
"transport_name",
[
"grpc",
"grpc_asyncio",
],
)
def test_connection_service_host_with_port(transport_name):
client = ConnectionServiceClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="apigeeconnect.googleapis.com:8000"
),
transport=transport_name,
)
assert client.transport._host == "apigeeconnect.googleapis.com:8000"
assert client.transport._host == ("apigeeconnect.googleapis.com:8000")


def test_connection_service_grpc_transport_channel():
Expand Down
Loading

0 comments on commit ed2de3a

Please sign in to comment.