Skip to content

Commit

Permalink
test: add transport in tests (#190)
Browse files Browse the repository at this point in the history
* fix: fix type in docstring for map fields

PiperOrigin-RevId: 440589618

Source-Link: googleapis/googleapis@cef1167

Source-Link: googleapis/googleapis-gen@0e0e2c9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGUwZTJjOTY1MjEwNDY2ODMyMzI2YzhlNTczNmRhNDYxMDU0YmNhNCJ9

* 🦉 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 9, 2022
1 parent 4c154a2 commit 194ece7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 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 @@ -334,7 +334,7 @@ def sample_list_approval_requests():
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.0,
),
Expand Down Expand Up @@ -447,7 +447,7 @@ def sample_get_approval_request():
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.0,
),
Expand Down Expand Up @@ -713,7 +713,7 @@ def sample_get_access_approval_settings():
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.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 @@ -493,7 +493,7 @@ def list_approval_requests(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_list_approval_requests():
# Create a client
Expand Down Expand Up @@ -603,7 +603,7 @@ def get_approval_request(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_get_approval_request():
# Create a client
Expand Down Expand Up @@ -700,7 +700,7 @@ def approve_approval_request(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_approve_approval_request():
# Create a client
Expand Down Expand Up @@ -783,7 +783,7 @@ def dismiss_approval_request(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_dismiss_approval_request():
# Create a client
Expand Down Expand Up @@ -859,7 +859,7 @@ def get_access_approval_settings(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_get_access_approval_settings():
# Create a client
Expand Down Expand Up @@ -961,7 +961,7 @@ def update_access_approval_settings(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_update_access_approval_settings():
# Create a client
Expand Down Expand Up @@ -1084,7 +1084,7 @@ def delete_access_approval_settings(
.. code-block:: python
from google.cloud import accessapproval_v1
from google.cloud import accessapproval_v1
def sample_delete_access_approval_settings():
# Create a client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,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 @@ -128,7 +129,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.0,
),
Expand All @@ -142,7 +143,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.0,
),
Expand All @@ -166,7 +167,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
core_exceptions.GoogleAPICallError,
),
deadline=600.0,
),
Expand Down Expand Up @@ -272,5 +273,9 @@ def delete_access_approval_settings(
]:
raise NotImplementedError()

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


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

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


__all__ = ("AccessApprovalGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,19 @@ def test_transport_adc(transport_class):
adc.assert_called_once()


@pytest.mark.parametrize(
"transport_name",
[
"grpc",
],
)
def test_transport_kind(transport_name):
transport = AccessApprovalClient.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 = AccessApprovalClient(
Expand Down Expand Up @@ -2576,6 +2589,14 @@ def test_access_approval_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_access_approval_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
Expand Down

0 comments on commit 194ece7

Please sign in to comment.