@@ -94,15 +94,19 @@ def test__get_default_mtls_endpoint():
94
94
)
95
95
96
96
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 ):
98
101
creds = credentials .AnonymousCredentials ()
99
102
with mock .patch .object (
100
103
service_account .Credentials , "from_service_account_info"
101
104
) as factory :
102
105
factory .return_value = creds
103
106
info = {"valid" : True }
104
- client = QuestionServiceClient .from_service_account_info (info )
107
+ client = client_class .from_service_account_info (info )
105
108
assert client .transport ._credentials == creds
109
+ assert isinstance (client , client_class )
106
110
107
111
assert client .transport ._host == "dataqna.googleapis.com:443"
108
112
@@ -118,9 +122,11 @@ def test_question_service_client_from_service_account_file(client_class):
118
122
factory .return_value = creds
119
123
client = client_class .from_service_account_file ("dummy/file/path.json" )
120
124
assert client .transport ._credentials == creds
125
+ assert isinstance (client , client_class )
121
126
122
127
client = client_class .from_service_account_json ("dummy/file/path.json" )
123
128
assert client .transport ._credentials == creds
129
+ assert isinstance (client , client_class )
124
130
125
131
assert client .transport ._host == "dataqna.googleapis.com:443"
126
132
@@ -505,6 +511,22 @@ def test_get_question_from_dict():
505
511
test_get_question (request_type = dict )
506
512
507
513
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
+
508
530
@pytest .mark .asyncio
509
531
async def test_get_question_async (
510
532
transport : str = "grpc_asyncio" , request_type = question_service .GetQuestionRequest
@@ -720,6 +742,22 @@ def test_create_question_from_dict():
720
742
test_create_question (request_type = dict )
721
743
722
744
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
+
723
761
@pytest .mark .asyncio
724
762
async def test_create_question_async (
725
763
transport : str = "grpc_asyncio" , request_type = question_service .CreateQuestionRequest
@@ -951,6 +989,22 @@ def test_execute_question_from_dict():
951
989
test_execute_question (request_type = dict )
952
990
953
991
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
+
954
1008
@pytest .mark .asyncio
955
1009
async def test_execute_question_async (
956
1010
transport : str = "grpc_asyncio" ,
@@ -1175,6 +1229,24 @@ def test_get_user_feedback_from_dict():
1175
1229
test_get_user_feedback (request_type = dict )
1176
1230
1177
1231
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
+
1178
1250
@pytest .mark .asyncio
1179
1251
async def test_get_user_feedback_async (
1180
1252
transport : str = "grpc_asyncio" ,
@@ -1395,6 +1467,24 @@ def test_update_user_feedback_from_dict():
1395
1467
test_update_user_feedback (request_type = dict )
1396
1468
1397
1469
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
+
1398
1488
@pytest .mark .asyncio
1399
1489
async def test_update_user_feedback_async (
1400
1490
transport : str = "grpc_asyncio" ,
0 commit comments