Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 56b6df1

Browse files
chore: update gapic-generator-python to 0.40.11
PiperOrigin-RevId: 359562873 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Feb 25 10:52:32 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 07932bb995e7dc91b43620ea8402c6668c7d102c Source-Link: googleapis/googleapis@07932bb
1 parent aa6b58a commit 56b6df1

File tree

6 files changed

+193
-10
lines changed

6 files changed

+193
-10
lines changed

google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,36 @@ class AutoSuggestionServiceAsyncClient:
145145
AutoSuggestionServiceClient.parse_common_location_path
146146
)
147147

148-
from_service_account_info = AutoSuggestionServiceClient.from_service_account_info
149-
from_service_account_file = AutoSuggestionServiceClient.from_service_account_file
148+
@classmethod
149+
def from_service_account_info(cls, info: dict, *args, **kwargs):
150+
"""Creates an instance of this client using the provided credentials info.
151+
152+
Args:
153+
info (dict): The service account private key info.
154+
args: Additional arguments to pass to the constructor.
155+
kwargs: Additional arguments to pass to the constructor.
156+
157+
Returns:
158+
AutoSuggestionServiceAsyncClient: The constructed client.
159+
"""
160+
return AutoSuggestionServiceClient.from_service_account_info.__func__(AutoSuggestionServiceAsyncClient, info, *args, **kwargs) # type: ignore
161+
162+
@classmethod
163+
def from_service_account_file(cls, filename: str, *args, **kwargs):
164+
"""Creates an instance of this client using the provided credentials
165+
file.
166+
167+
Args:
168+
filename (str): The path to the service account private key json
169+
file.
170+
args: Additional arguments to pass to the constructor.
171+
kwargs: Additional arguments to pass to the constructor.
172+
173+
Returns:
174+
AutoSuggestionServiceAsyncClient: The constructed client.
175+
"""
176+
return AutoSuggestionServiceClient.from_service_account_file.__func__(AutoSuggestionServiceAsyncClient, filename, *args, **kwargs) # type: ignore
177+
150178
from_service_account_json = from_service_account_file
151179

152180
@property

google/cloud/dataqna_v1alpha/services/question_service/async_client.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,36 @@ class QuestionServiceAsyncClient:
103103
QuestionServiceClient.parse_common_location_path
104104
)
105105

106-
from_service_account_info = QuestionServiceClient.from_service_account_info
107-
from_service_account_file = QuestionServiceClient.from_service_account_file
106+
@classmethod
107+
def from_service_account_info(cls, info: dict, *args, **kwargs):
108+
"""Creates an instance of this client using the provided credentials info.
109+
110+
Args:
111+
info (dict): The service account private key info.
112+
args: Additional arguments to pass to the constructor.
113+
kwargs: Additional arguments to pass to the constructor.
114+
115+
Returns:
116+
QuestionServiceAsyncClient: The constructed client.
117+
"""
118+
return QuestionServiceClient.from_service_account_info.__func__(QuestionServiceAsyncClient, info, *args, **kwargs) # type: ignore
119+
120+
@classmethod
121+
def from_service_account_file(cls, filename: str, *args, **kwargs):
122+
"""Creates an instance of this client using the provided credentials
123+
file.
124+
125+
Args:
126+
filename (str): The path to the service account private key json
127+
file.
128+
args: Additional arguments to pass to the constructor.
129+
kwargs: Additional arguments to pass to the constructor.
130+
131+
Returns:
132+
QuestionServiceAsyncClient: The constructed client.
133+
"""
134+
return QuestionServiceClient.from_service_account_file.__func__(QuestionServiceAsyncClient, filename, *args, **kwargs) # type: ignore
135+
108136
from_service_account_json = from_service_account_file
109137

110138
@property

synth.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "20712b8fe95001b312f62c6c5f33e3e3ec92cfaf",
15-
"internalRef": "354996675"
14+
"sha": "07932bb995e7dc91b43620ea8402c6668c7d102c",
15+
"internalRef": "359562873"
1616
}
1717
}
1818
],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
# -*- coding: utf-8 -*-
12

3+
# Copyright 2020 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#

tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ def test__get_default_mtls_endpoint():
8888
)
8989

9090

91-
def test_auto_suggestion_service_client_from_service_account_info():
91+
@pytest.mark.parametrize(
92+
"client_class", [AutoSuggestionServiceClient, AutoSuggestionServiceAsyncClient,]
93+
)
94+
def test_auto_suggestion_service_client_from_service_account_info(client_class):
9295
creds = credentials.AnonymousCredentials()
9396
with mock.patch.object(
9497
service_account.Credentials, "from_service_account_info"
9598
) as factory:
9699
factory.return_value = creds
97100
info = {"valid": True}
98-
client = AutoSuggestionServiceClient.from_service_account_info(info)
101+
client = client_class.from_service_account_info(info)
99102
assert client.transport._credentials == creds
103+
assert isinstance(client, client_class)
100104

101105
assert client.transport._host == "dataqna.googleapis.com:443"
102106

@@ -112,9 +116,11 @@ def test_auto_suggestion_service_client_from_service_account_file(client_class):
112116
factory.return_value = creds
113117
client = client_class.from_service_account_file("dummy/file/path.json")
114118
assert client.transport._credentials == creds
119+
assert isinstance(client, client_class)
115120

116121
client = client_class.from_service_account_json("dummy/file/path.json")
117122
assert client.transport._credentials == creds
123+
assert isinstance(client, client_class)
118124

119125
assert client.transport._host == "dataqna.googleapis.com:443"
120126

@@ -495,6 +501,22 @@ def test_suggest_queries_from_dict():
495501
test_suggest_queries(request_type=dict)
496502

497503

504+
def test_suggest_queries_empty_call():
505+
# This test is a coverage failsafe to make sure that totally empty calls,
506+
# i.e. request == None and no flattened fields passed, work.
507+
client = AutoSuggestionServiceClient(
508+
credentials=credentials.AnonymousCredentials(), transport="grpc",
509+
)
510+
511+
# Mock the actual call within the gRPC stub, and fake the request.
512+
with mock.patch.object(type(client.transport.suggest_queries), "__call__") as call:
513+
client.suggest_queries()
514+
call.assert_called()
515+
_, args, _ = call.mock_calls[0]
516+
517+
assert args[0] == auto_suggestion_service.SuggestQueriesRequest()
518+
519+
498520
@pytest.mark.asyncio
499521
async def test_suggest_queries_async(
500522
transport: str = "grpc_asyncio",

tests/unit/gapic/dataqna_v1alpha/test_question_service.py

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,19 @@ def test__get_default_mtls_endpoint():
9494
)
9595

9696

97-
def test_question_service_client_from_service_account_info():
97+
@pytest.mark.parametrize(
98+
"client_class", [QuestionServiceClient, QuestionServiceAsyncClient,]
99+
)
100+
def test_question_service_client_from_service_account_info(client_class):
98101
creds = credentials.AnonymousCredentials()
99102
with mock.patch.object(
100103
service_account.Credentials, "from_service_account_info"
101104
) as factory:
102105
factory.return_value = creds
103106
info = {"valid": True}
104-
client = QuestionServiceClient.from_service_account_info(info)
107+
client = client_class.from_service_account_info(info)
105108
assert client.transport._credentials == creds
109+
assert isinstance(client, client_class)
106110

107111
assert client.transport._host == "dataqna.googleapis.com:443"
108112

@@ -118,9 +122,11 @@ def test_question_service_client_from_service_account_file(client_class):
118122
factory.return_value = creds
119123
client = client_class.from_service_account_file("dummy/file/path.json")
120124
assert client.transport._credentials == creds
125+
assert isinstance(client, client_class)
121126

122127
client = client_class.from_service_account_json("dummy/file/path.json")
123128
assert client.transport._credentials == creds
129+
assert isinstance(client, client_class)
124130

125131
assert client.transport._host == "dataqna.googleapis.com:443"
126132

@@ -505,6 +511,22 @@ def test_get_question_from_dict():
505511
test_get_question(request_type=dict)
506512

507513

514+
def test_get_question_empty_call():
515+
# This test is a coverage failsafe to make sure that totally empty calls,
516+
# i.e. request == None and no flattened fields passed, work.
517+
client = QuestionServiceClient(
518+
credentials=credentials.AnonymousCredentials(), transport="grpc",
519+
)
520+
521+
# Mock the actual call within the gRPC stub, and fake the request.
522+
with mock.patch.object(type(client.transport.get_question), "__call__") as call:
523+
client.get_question()
524+
call.assert_called()
525+
_, args, _ = call.mock_calls[0]
526+
527+
assert args[0] == question_service.GetQuestionRequest()
528+
529+
508530
@pytest.mark.asyncio
509531
async def test_get_question_async(
510532
transport: str = "grpc_asyncio", request_type=question_service.GetQuestionRequest
@@ -720,6 +742,22 @@ def test_create_question_from_dict():
720742
test_create_question(request_type=dict)
721743

722744

745+
def test_create_question_empty_call():
746+
# This test is a coverage failsafe to make sure that totally empty calls,
747+
# i.e. request == None and no flattened fields passed, work.
748+
client = QuestionServiceClient(
749+
credentials=credentials.AnonymousCredentials(), transport="grpc",
750+
)
751+
752+
# Mock the actual call within the gRPC stub, and fake the request.
753+
with mock.patch.object(type(client.transport.create_question), "__call__") as call:
754+
client.create_question()
755+
call.assert_called()
756+
_, args, _ = call.mock_calls[0]
757+
758+
assert args[0] == question_service.CreateQuestionRequest()
759+
760+
723761
@pytest.mark.asyncio
724762
async def test_create_question_async(
725763
transport: str = "grpc_asyncio", request_type=question_service.CreateQuestionRequest
@@ -951,6 +989,22 @@ def test_execute_question_from_dict():
951989
test_execute_question(request_type=dict)
952990

953991

992+
def test_execute_question_empty_call():
993+
# This test is a coverage failsafe to make sure that totally empty calls,
994+
# i.e. request == None and no flattened fields passed, work.
995+
client = QuestionServiceClient(
996+
credentials=credentials.AnonymousCredentials(), transport="grpc",
997+
)
998+
999+
# Mock the actual call within the gRPC stub, and fake the request.
1000+
with mock.patch.object(type(client.transport.execute_question), "__call__") as call:
1001+
client.execute_question()
1002+
call.assert_called()
1003+
_, args, _ = call.mock_calls[0]
1004+
1005+
assert args[0] == question_service.ExecuteQuestionRequest()
1006+
1007+
9541008
@pytest.mark.asyncio
9551009
async def test_execute_question_async(
9561010
transport: str = "grpc_asyncio",
@@ -1175,6 +1229,24 @@ def test_get_user_feedback_from_dict():
11751229
test_get_user_feedback(request_type=dict)
11761230

11771231

1232+
def test_get_user_feedback_empty_call():
1233+
# This test is a coverage failsafe to make sure that totally empty calls,
1234+
# i.e. request == None and no flattened fields passed, work.
1235+
client = QuestionServiceClient(
1236+
credentials=credentials.AnonymousCredentials(), transport="grpc",
1237+
)
1238+
1239+
# Mock the actual call within the gRPC stub, and fake the request.
1240+
with mock.patch.object(
1241+
type(client.transport.get_user_feedback), "__call__"
1242+
) as call:
1243+
client.get_user_feedback()
1244+
call.assert_called()
1245+
_, args, _ = call.mock_calls[0]
1246+
1247+
assert args[0] == question_service.GetUserFeedbackRequest()
1248+
1249+
11781250
@pytest.mark.asyncio
11791251
async def test_get_user_feedback_async(
11801252
transport: str = "grpc_asyncio",
@@ -1395,6 +1467,24 @@ def test_update_user_feedback_from_dict():
13951467
test_update_user_feedback(request_type=dict)
13961468

13971469

1470+
def test_update_user_feedback_empty_call():
1471+
# This test is a coverage failsafe to make sure that totally empty calls,
1472+
# i.e. request == None and no flattened fields passed, work.
1473+
client = QuestionServiceClient(
1474+
credentials=credentials.AnonymousCredentials(), transport="grpc",
1475+
)
1476+
1477+
# Mock the actual call within the gRPC stub, and fake the request.
1478+
with mock.patch.object(
1479+
type(client.transport.update_user_feedback), "__call__"
1480+
) as call:
1481+
client.update_user_feedback()
1482+
call.assert_called()
1483+
_, args, _ = call.mock_calls[0]
1484+
1485+
assert args[0] == question_service.UpdateUserFeedbackRequest()
1486+
1487+
13981488
@pytest.mark.asyncio
13991489
async def test_update_user_feedback_async(
14001490
transport: str = "grpc_asyncio",

0 commit comments

Comments
 (0)