|
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | 15 | # |
16 | | -import os |
17 | 16 | import asyncio |
| 17 | +import json |
| 18 | +import math |
| 19 | +import os |
| 20 | +from collections.abc import AsyncIterable, Iterable, Mapping, Sequence |
18 | 21 | from unittest import mock |
19 | 22 | from unittest.mock import AsyncMock |
20 | 23 |
|
21 | 24 | import grpc |
22 | | -from grpc.experimental import aio |
23 | | -from collections.abc import Iterable, AsyncIterable |
24 | | -from google.protobuf import json_format |
25 | | -import json |
26 | | -import math |
27 | 25 | import pytest |
28 | | -from collections.abc import Sequence, Mapping |
29 | 26 | from google.api_core import api_core_version |
30 | | -from proto.marshal.rules.dates import DurationRule, TimestampRule |
| 27 | +from google.protobuf import json_format |
| 28 | +from grpc.experimental import aio |
31 | 29 | from proto.marshal.rules import wrappers |
32 | | -from requests import Response |
33 | | -from requests import Request, PreparedRequest |
| 30 | +from proto.marshal.rules.dates import DurationRule, TimestampRule |
| 31 | +from requests import PreparedRequest, Request, Response |
34 | 32 | from requests.sessions import Session |
35 | | -from google.protobuf import json_format |
36 | 33 |
|
37 | 34 | try: |
38 | 35 | from google.auth.aio import credentials as ga_credentials_async |
39 | 36 | HAS_GOOGLE_AUTH_AIO = True |
40 | 37 | except ImportError: # pragma: NO COVER |
41 | 38 | HAS_GOOGLE_AUTH_AIO = False |
42 | 39 |
|
43 | | -from google.api_core import client_options |
| 40 | +import google.api_core.operation_async as operation_async # type: ignore |
| 41 | +import google.auth |
| 42 | +import google.protobuf.duration_pb2 as duration_pb2 # type: ignore |
| 43 | +import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore |
| 44 | +import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore |
| 45 | +import google.rpc.code_pb2 as code_pb2 # type: ignore |
| 46 | +from google.api_core import ( |
| 47 | + client_options, |
| 48 | + future, |
| 49 | + gapic_v1, |
| 50 | + grpc_helpers, |
| 51 | + grpc_helpers_async, |
| 52 | + operation, |
| 53 | + operations_v1, |
| 54 | + path_template, |
| 55 | +) |
44 | 56 | from google.api_core import exceptions as core_exceptions |
45 | | -from google.api_core import future |
46 | | -from google.api_core import gapic_v1 |
47 | | -from google.api_core import grpc_helpers |
48 | | -from google.api_core import grpc_helpers_async |
49 | | -from google.api_core import operation |
50 | | -from google.api_core import operations_v1 |
51 | | -from google.api_core import path_template |
52 | 57 | from google.api_core import retry as retries |
53 | 58 | from google.auth import credentials as ga_credentials |
54 | 59 | from google.auth.exceptions import MutualTLSChannelError |
55 | | -from google.cloud.eventarc_v1.services.eventarc import EventarcAsyncClient |
56 | | -from google.cloud.eventarc_v1.services.eventarc import EventarcClient |
57 | | -from google.cloud.eventarc_v1.services.eventarc import pagers |
58 | | -from google.cloud.eventarc_v1.services.eventarc import transports |
59 | | -from google.cloud.eventarc_v1.types import channel |
| 60 | +from google.cloud.eventarc_v1.services.eventarc import ( |
| 61 | + EventarcAsyncClient, |
| 62 | + EventarcClient, |
| 63 | + pagers, |
| 64 | + transports, |
| 65 | +) |
| 66 | +from google.cloud.eventarc_v1.types import ( |
| 67 | + channel, |
| 68 | + channel_connection, |
| 69 | + discovery, |
| 70 | + enrollment, |
| 71 | + eventarc, |
| 72 | + google_api_source, |
| 73 | + google_channel_config, |
| 74 | + logging_config, |
| 75 | + message_bus, |
| 76 | + network_config, |
| 77 | + pipeline, |
| 78 | + trigger, |
| 79 | +) |
60 | 80 | from google.cloud.eventarc_v1.types import channel as gce_channel |
61 | | -from google.cloud.eventarc_v1.types import channel_connection |
62 | 81 | from google.cloud.eventarc_v1.types import channel_connection as gce_channel_connection |
63 | | -from google.cloud.eventarc_v1.types import discovery |
64 | | -from google.cloud.eventarc_v1.types import enrollment |
65 | 82 | from google.cloud.eventarc_v1.types import enrollment as gce_enrollment |
66 | | -from google.cloud.eventarc_v1.types import eventarc |
67 | | -from google.cloud.eventarc_v1.types import google_api_source |
68 | 83 | from google.cloud.eventarc_v1.types import google_api_source as gce_google_api_source |
69 | | -from google.cloud.eventarc_v1.types import google_channel_config |
70 | | -from google.cloud.eventarc_v1.types import google_channel_config as gce_google_channel_config |
71 | | -from google.cloud.eventarc_v1.types import logging_config |
72 | | -from google.cloud.eventarc_v1.types import message_bus |
| 84 | +from google.cloud.eventarc_v1.types import ( |
| 85 | + google_channel_config as gce_google_channel_config, |
| 86 | +) |
73 | 87 | from google.cloud.eventarc_v1.types import message_bus as gce_message_bus |
74 | | -from google.cloud.eventarc_v1.types import network_config |
75 | | -from google.cloud.eventarc_v1.types import pipeline |
76 | 88 | from google.cloud.eventarc_v1.types import pipeline as gce_pipeline |
77 | | -from google.cloud.eventarc_v1.types import trigger |
78 | 89 | from google.cloud.eventarc_v1.types import trigger as gce_trigger |
79 | 90 | from google.cloud.location import locations_pb2 |
80 | | -from google.iam.v1 import iam_policy_pb2 # type: ignore |
81 | | -from google.iam.v1 import options_pb2 # type: ignore |
82 | | -from google.iam.v1 import policy_pb2 # type: ignore |
83 | | -from google.longrunning import operations_pb2 # type: ignore |
| 91 | +from google.iam.v1 import ( |
| 92 | + iam_policy_pb2, # type: ignore |
| 93 | + options_pb2, # type: ignore |
| 94 | + policy_pb2, # type: ignore |
| 95 | +) |
| 96 | +from google.longrunning import operations_pb2 # type: ignore |
84 | 97 | from google.oauth2 import service_account |
85 | | -import google.api_core.operation_async as operation_async # type: ignore |
86 | | -import google.auth |
87 | | -import google.protobuf.duration_pb2 as duration_pb2 # type: ignore |
88 | | -import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore |
89 | | -import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore |
90 | | -import google.rpc.code_pb2 as code_pb2 # type: ignore |
91 | | - |
92 | | - |
93 | 98 |
|
94 | 99 | CRED_INFO_JSON = { |
95 | 100 | "credential_source": "/path/to/file", |
@@ -721,7 +726,7 @@ def test_eventarc_client_get_mtls_endpoint_and_cert_source(client_class): |
721 | 726 | config_filename = "mock_certificate_config.json" |
722 | 727 | config_file_content = json.dumps(config_data) |
723 | 728 | m = mock.mock_open(read_data=config_file_content) |
724 | | - with mock.patch("builtins.open", m), mock.patch("os.path.exists", return_value=True): |
| 729 | + with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename): |
725 | 730 | with mock.patch.dict( |
726 | 731 | os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename} |
727 | 732 | ): |
@@ -768,7 +773,7 @@ def test_eventarc_client_get_mtls_endpoint_and_cert_source(client_class): |
768 | 773 | config_filename = "mock_certificate_config.json" |
769 | 774 | config_file_content = json.dumps(config_data) |
770 | 775 | m = mock.mock_open(read_data=config_file_content) |
771 | | - with mock.patch("builtins.open", m), mock.patch("os.path.exists", return_value=True): |
| 776 | + with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename): |
772 | 777 | with mock.patch.dict( |
773 | 778 | os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename} |
774 | 779 | ): |
|
0 commit comments