@@ -82,15 +82,17 @@ def test__get_default_mtls_endpoint():
82
82
assert OrgPolicyClient ._get_default_mtls_endpoint (non_googleapi ) == non_googleapi
83
83
84
84
85
- def test_org_policy_client_from_service_account_info ():
85
+ @pytest .mark .parametrize ("client_class" , [OrgPolicyClient , OrgPolicyAsyncClient ,])
86
+ def test_org_policy_client_from_service_account_info (client_class ):
86
87
creds = credentials .AnonymousCredentials ()
87
88
with mock .patch .object (
88
89
service_account .Credentials , "from_service_account_info"
89
90
) as factory :
90
91
factory .return_value = creds
91
92
info = {"valid" : True }
92
- client = OrgPolicyClient .from_service_account_info (info )
93
+ client = client_class .from_service_account_info (info )
93
94
assert client .transport ._credentials == creds
95
+ assert isinstance (client , client_class )
94
96
95
97
assert client .transport ._host == "orgpolicy.googleapis.com:443"
96
98
@@ -104,9 +106,11 @@ def test_org_policy_client_from_service_account_file(client_class):
104
106
factory .return_value = creds
105
107
client = client_class .from_service_account_file ("dummy/file/path.json" )
106
108
assert client .transport ._credentials == creds
109
+ assert isinstance (client , client_class )
107
110
108
111
client = client_class .from_service_account_json ("dummy/file/path.json" )
109
112
assert client .transport ._credentials == creds
113
+ assert isinstance (client , client_class )
110
114
111
115
assert client .transport ._host == "orgpolicy.googleapis.com:443"
112
116
@@ -463,6 +467,22 @@ def test_list_constraints_from_dict():
463
467
test_list_constraints (request_type = dict )
464
468
465
469
470
+ def test_list_constraints_empty_call ():
471
+ # This test is a coverage failsafe to make sure that totally empty calls,
472
+ # i.e. request == None and no flattened fields passed, work.
473
+ client = OrgPolicyClient (
474
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
475
+ )
476
+
477
+ # Mock the actual call within the gRPC stub, and fake the request.
478
+ with mock .patch .object (type (client .transport .list_constraints ), "__call__" ) as call :
479
+ client .list_constraints ()
480
+ call .assert_called ()
481
+ _ , args , _ = call .mock_calls [0 ]
482
+
483
+ assert args [0 ] == orgpolicy .ListConstraintsRequest ()
484
+
485
+
466
486
@pytest .mark .asyncio
467
487
async def test_list_constraints_async (
468
488
transport : str = "grpc_asyncio" , request_type = orgpolicy .ListConstraintsRequest
@@ -794,6 +814,22 @@ def test_list_policies_from_dict():
794
814
test_list_policies (request_type = dict )
795
815
796
816
817
+ def test_list_policies_empty_call ():
818
+ # This test is a coverage failsafe to make sure that totally empty calls,
819
+ # i.e. request == None and no flattened fields passed, work.
820
+ client = OrgPolicyClient (
821
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
822
+ )
823
+
824
+ # Mock the actual call within the gRPC stub, and fake the request.
825
+ with mock .patch .object (type (client .transport .list_policies ), "__call__" ) as call :
826
+ client .list_policies ()
827
+ call .assert_called ()
828
+ _ , args , _ = call .mock_calls [0 ]
829
+
830
+ assert args [0 ] == orgpolicy .ListPoliciesRequest ()
831
+
832
+
797
833
@pytest .mark .asyncio
798
834
async def test_list_policies_async (
799
835
transport : str = "grpc_asyncio" , request_type = orgpolicy .ListPoliciesRequest
@@ -1105,6 +1141,22 @@ def test_get_policy_from_dict():
1105
1141
test_get_policy (request_type = dict )
1106
1142
1107
1143
1144
+ def test_get_policy_empty_call ():
1145
+ # This test is a coverage failsafe to make sure that totally empty calls,
1146
+ # i.e. request == None and no flattened fields passed, work.
1147
+ client = OrgPolicyClient (
1148
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
1149
+ )
1150
+
1151
+ # Mock the actual call within the gRPC stub, and fake the request.
1152
+ with mock .patch .object (type (client .transport .get_policy ), "__call__" ) as call :
1153
+ client .get_policy ()
1154
+ call .assert_called ()
1155
+ _ , args , _ = call .mock_calls [0 ]
1156
+
1157
+ assert args [0 ] == orgpolicy .GetPolicyRequest ()
1158
+
1159
+
1108
1160
@pytest .mark .asyncio
1109
1161
async def test_get_policy_async (
1110
1162
transport : str = "grpc_asyncio" , request_type = orgpolicy .GetPolicyRequest
@@ -1294,6 +1346,24 @@ def test_get_effective_policy_from_dict():
1294
1346
test_get_effective_policy (request_type = dict )
1295
1347
1296
1348
1349
+ def test_get_effective_policy_empty_call ():
1350
+ # This test is a coverage failsafe to make sure that totally empty calls,
1351
+ # i.e. request == None and no flattened fields passed, work.
1352
+ client = OrgPolicyClient (
1353
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
1354
+ )
1355
+
1356
+ # Mock the actual call within the gRPC stub, and fake the request.
1357
+ with mock .patch .object (
1358
+ type (client .transport .get_effective_policy ), "__call__"
1359
+ ) as call :
1360
+ client .get_effective_policy ()
1361
+ call .assert_called ()
1362
+ _ , args , _ = call .mock_calls [0 ]
1363
+
1364
+ assert args [0 ] == orgpolicy .GetEffectivePolicyRequest ()
1365
+
1366
+
1297
1367
@pytest .mark .asyncio
1298
1368
async def test_get_effective_policy_async (
1299
1369
transport : str = "grpc_asyncio" , request_type = orgpolicy .GetEffectivePolicyRequest
@@ -1491,6 +1561,22 @@ def test_create_policy_from_dict():
1491
1561
test_create_policy (request_type = dict )
1492
1562
1493
1563
1564
+ def test_create_policy_empty_call ():
1565
+ # This test is a coverage failsafe to make sure that totally empty calls,
1566
+ # i.e. request == None and no flattened fields passed, work.
1567
+ client = OrgPolicyClient (
1568
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
1569
+ )
1570
+
1571
+ # Mock the actual call within the gRPC stub, and fake the request.
1572
+ with mock .patch .object (type (client .transport .create_policy ), "__call__" ) as call :
1573
+ client .create_policy ()
1574
+ call .assert_called ()
1575
+ _ , args , _ = call .mock_calls [0 ]
1576
+
1577
+ assert args [0 ] == orgpolicy .CreatePolicyRequest ()
1578
+
1579
+
1494
1580
@pytest .mark .asyncio
1495
1581
async def test_create_policy_async (
1496
1582
transport : str = "grpc_asyncio" , request_type = orgpolicy .CreatePolicyRequest
@@ -1690,6 +1776,22 @@ def test_update_policy_from_dict():
1690
1776
test_update_policy (request_type = dict )
1691
1777
1692
1778
1779
+ def test_update_policy_empty_call ():
1780
+ # This test is a coverage failsafe to make sure that totally empty calls,
1781
+ # i.e. request == None and no flattened fields passed, work.
1782
+ client = OrgPolicyClient (
1783
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
1784
+ )
1785
+
1786
+ # Mock the actual call within the gRPC stub, and fake the request.
1787
+ with mock .patch .object (type (client .transport .update_policy ), "__call__" ) as call :
1788
+ client .update_policy ()
1789
+ call .assert_called ()
1790
+ _ , args , _ = call .mock_calls [0 ]
1791
+
1792
+ assert args [0 ] == orgpolicy .UpdatePolicyRequest ()
1793
+
1794
+
1693
1795
@pytest .mark .asyncio
1694
1796
async def test_update_policy_async (
1695
1797
transport : str = "grpc_asyncio" , request_type = orgpolicy .UpdatePolicyRequest
@@ -1876,6 +1978,22 @@ def test_delete_policy_from_dict():
1876
1978
test_delete_policy (request_type = dict )
1877
1979
1878
1980
1981
+ def test_delete_policy_empty_call ():
1982
+ # This test is a coverage failsafe to make sure that totally empty calls,
1983
+ # i.e. request == None and no flattened fields passed, work.
1984
+ client = OrgPolicyClient (
1985
+ credentials = credentials .AnonymousCredentials (), transport = "grpc" ,
1986
+ )
1987
+
1988
+ # Mock the actual call within the gRPC stub, and fake the request.
1989
+ with mock .patch .object (type (client .transport .delete_policy ), "__call__" ) as call :
1990
+ client .delete_policy ()
1991
+ call .assert_called ()
1992
+ _ , args , _ = call .mock_calls [0 ]
1993
+
1994
+ assert args [0 ] == orgpolicy .DeletePolicyRequest ()
1995
+
1996
+
1879
1997
@pytest .mark .asyncio
1880
1998
async def test_delete_policy_async (
1881
1999
transport : str = "grpc_asyncio" , request_type = orgpolicy .DeletePolicyRequest
0 commit comments