uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6c27d2344856fd6b17e02c0c | train | function | @pytest.mark.asyncio
async def test_delete_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.DeleteServiceAccountKeyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as fa... | @pytest.mark.asyncio
async def test_delete_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.DeleteServiceAccountKeyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | client.delete_service_account_key()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.DeleteServiceAccountKeyRequest()
@pytest.mark.asyncio
async def test_delete_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.DeleteServiceAccountKeyRe... | 71 | 71 | 239 | 33 | 38 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_key_async | test_delete_service_account_key_async | 3,365 | 3,390 | 3,365 | 3,366 | 58968bda80b7ccb92041111bc8dd1b3bf43c12af | bigcode/the-stack | train |
14e6b79a6859de694870b6f2 | train | function | def test_test_iam_permissions_flattened():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.test_iam_permissions),
'__call__') as call... | def test_test_iam_permissions_flattened():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.test_iam_permissions),
'__call__') as call:
# Designate an appropriate return... | value for the call.
call.return_value = iam_policy_pb2.TestIamPermissionsResponse()
response = client.test_iam_permissions(request={
'resource': 'resource_value',
'permissions': ['permissions_value'],
}
)
call.assert_called()
def test_test_iam_permiss... | 64 | 64 | 205 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions_flattened | test_test_iam_permissions_flattened | 4,695 | 4,718 | 4,695 | 4,695 | 3f6f5abb3e6ed847c7f5b3290f0bb13e44cd76b7 | bigcode/the-stack | train |
967ed43267d7f369e56ec82e | train | function | def test_delete_service_account_flattened():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.delete_service_account),
'__call__') as ... | def test_delete_service_account_flattened():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.delete_service_account),
'__call__') as call:
# Designate an appropriate retu... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
def test_delete_service_account_flattened():
| 64 | 64 | 177 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_flattened | test_delete_service_account_flattened | 1,863 | 1,884 | 1,863 | 1,863 | 933eaa7bf65a9851a5a3b4fc543167fab672cedf | bigcode/the-stack | train |
eefb51a7381b67fc4d6ab6ad | train | function | def test_create_service_account_key_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.create_service_account_... | def test_create_service_account_key_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.create_service_account_key(
iam.CreateServiceAccountKeyRequest(),
... | [0].name == 'name_value'
assert args[0].private_key_type == iam.ServiceAccountPrivateKeyType.TYPE_PKCS12_FILE
assert args[0].key_algorithm == iam.ServiceAccountKeyAlgorithm.KEY_ALG_RSA_1024
def test_create_service_account_key_flattened_error():
| 64 | 64 | 115 | 11 | 52 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_key_flattened_error | test_create_service_account_key_flattened_error | 3,077 | 3,090 | 3,077 | 3,077 | 582aa60c2a275ded3997d3d40679c7d67e7f5ba9 | bigcode/the-stack | train |
dbd7b345ea0793eba77f3866 | train | function | @pytest.mark.asyncio
async def test_set_iam_policy_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam_policy_pb2.S... | @pytest.mark.asyncio
async def test_set_iam_policy_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam_policy_pb2.SetIamPolicyRequest()
request.resource = 'resource/value'
# Mock ... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'resource=resource/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_set_iam_policy_field_headers_async():
| 72 | 72 | 243 | 16 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_field_headers_async | test_set_iam_policy_field_headers_async | 4,398 | 4,427 | 4,398 | 4,399 | fde97e95376635e61a0edc6776d755f44479840a | bigcode/the-stack | train |
190a6df1fa301b830fbd8f24 | train | function | @pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_info(client_class):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory:
factory.return_value = ... | @pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_info(client_class):
| creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory:
factory.return_value = creds
info = {"valid": True}
client = client_class.from_service_account_info(info)
assert client.transport._credential... | _mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint
assert IAMClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
@pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_info(client_class):
| 64 | 64 | 115 | 30 | 33 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_from_service_account_info | test_iam_client_from_service_account_info | 90 | 103 | 90 | 94 | fca0f90bb9e9e8d467cdc22d1c8d2213b77817eb | bigcode/the-stack | train |
33620463a89e2d88551c7d80 | train | function | @pytest.mark.parametrize(
"transport_class,grpc_helpers",
[
(transports.IAMGrpcTransport, grpc_helpers),
(transports.IAMGrpcAsyncIOTransport, grpc_helpers_async)
],
)
def test_iam_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the tra... | @pytest.mark.parametrize(
"transport_class,grpc_helpers",
[
(transports.IAMGrpcTransport, grpc_helpers),
(transports.IAMGrpcAsyncIOTransport, grpc_helpers_async)
],
)
def test_iam_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the tra... | with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object(
grpc_helpers, "create_channel", autospec=True
) as create_channel:
creds = ga_credentials.AnonymousCredentials()
adc.return_value = (creds, None)
transport_class(
quota_project_id... | @pytest.mark.parametrize(
"transport_class,grpc_helpers",
[
(transports.IAMGrpcTransport, grpc_helpers),
(transports.IAMGrpcAsyncIOTransport, grpc_helpers_async)
],
)
def test_iam_transport_create_channel(transport_class, grpc_helpers):
# If credentials and host are not provided, the tra... | 79 | 79 | 264 | 79 | 0 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_transport_create_channel | test_iam_transport_create_channel | 6,958 | 6,993 | 6,958 | 6,967 | 21ab9ee9c6dd211fbd5388fe764f99bb7bce479b | bigcode/the-stack | train |
ce8a22b7305036349abbf650 | train | function | @pytest.mark.asyncio
async def test_set_iam_policy_flattened_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.set_iam_policy),
... | @pytest.mark.asyncio
async def test_set_iam_policy_flattened_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.set_iam_policy),
'__call__') as call:
# Designate an appropriate return ... | with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.set_iam_policy(
iam_policy_pb2.SetIamPolicyRequest(),
resource='resource_value',
)
@pytest.mark.asyncio
async def test_set_iam_policy_flattened_async():
| 64 | 64 | 208 | 17 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_flattened_async | test_set_iam_policy_flattened_async | 4,485 | 4,509 | 4,485 | 4,486 | 12f5dd80b957b9aecb5b4ec36976203766c50ae4 | bigcode/the-stack | train |
4992e8c4adf09798627cc436 | train | function | def test_delete_service_account_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.delete_service_account(
... | def test_delete_service_account_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.delete_service_account(
iam.DeleteServiceAccountRequest(),
... | # Establish that the underlying call was made with the expected
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
def test_delete_service_account_flattened_error():
| 64 | 64 | 78 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_flattened_error | test_delete_service_account_flattened_error | 1,887 | 1,898 | 1,887 | 1,887 | f156fb388b252788ae22ee52cfa7c0bfae3df54e | bigcode/the-stack | train |
ab9cbd479ef491cffd234d21 | train | function | @requires_google_auth_gte_1_25_0
def test_iam_auth_adc():
# If no credentials are provided, we should use ADC credentials.
with mock.patch.object(google.auth, 'default', autospec=True) as adc:
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
IAMClient()
adc.assert_called_... | @requires_google_auth_gte_1_25_0
def test_iam_auth_adc():
# If no credentials are provided, we should use ADC credentials.
| with mock.patch.object(google.auth, 'default', autospec=True) as adc:
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
IAMClient()
adc.assert_called_once_with(
scopes=None,
default_scopes=(
'https://www.googleapis.com/auth/cloud-platform',
... | None
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.IAMTransport()
adc.assert_called_once()
@requires_google_auth_gte_1_25_0
def test_iam_auth_adc():
# If no credentials are provided, we should use ADC credentials.
| 64 | 64 | 108 | 34 | 30 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_auth_adc | test_iam_auth_adc | 6,889 | 6,901 | 6,889 | 6,891 | fda738c369932f3d57cac72b83f8d49c772122a3 | bigcode/the-stack | train |
dc0a6f3292cd1c5b1654dd59 | train | function | @pytest.mark.asyncio
async def test_get_service_account_key_flattened_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_a... | @pytest.mark.asyncio
async def test_get_service_account_key_flattened_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_account_key),
'__call__') as call:
# Designate an appropriat... | and flattened
# fields is an error.
with pytest.raises(ValueError):
client.get_service_account_key(
iam.GetServiceAccountKeyRequest(),
name='name_value',
public_key_type=iam.ServiceAccountPublicKeyType.TYPE_X509_PEM_FILE,
)
@pytest.mark.asyncio
async def test... | 75 | 75 | 250 | 17 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_key_flattened_async | test_get_service_account_key_flattened_async | 2,829 | 2,855 | 2,829 | 2,830 | a93e9b6c331748c9a4f3d4a1afa33d385990879e | bigcode/the-stack | train |
f94f5781ad120a493c3e92df | train | function | @pytest.mark.asyncio
async def test_create_role_async(transport: str = 'grpc_asyncio', request_type=iam.CreateRoleRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerne... | @pytest.mark.asyncio
async def test_create_role_async(transport: str = 'grpc_asyncio', request_type=iam.CreateRoleRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | ='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.create_role),
'__call__') as call:
client.create_role()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == ... | 106 | 106 | 354 | 29 | 77 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_role_async | test_create_role_async | 5,638 | 5,678 | 5,638 | 5,639 | b6b110e93ffe87cfadb36b822edb9f15881e76ad | bigcode/the-stack | train |
09d20194523b8719becbd996 | train | function | def modify_default_endpoint(client):
return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT
| def modify_default_endpoint(client):
| return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT
| client_cert_source_callback():
return b"cert bytes", b"key bytes"
# If default endpoint is localhost, then default mtls endpoint will be the same.
# This method modifies the default endpoint so the client can produce a different
# mtls endpoint for endpoint testing purposes.
def modify_default_endpoint(client):
| 64 | 64 | 27 | 6 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | modify_default_endpoint | modify_default_endpoint | 71 | 72 | 71 | 71 | 962b74e6cc0b535d1164c40ab078fdbe689e2841 | bigcode/the-stack | train |
a6a722f3780be32e2ada1b22 | train | function | @pytest.mark.asyncio
async def test_delete_service_account_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.Dele... | @pytest.mark.asyncio
async def test_delete_service_account_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.DeleteServiceAccountRequest()
request.name = 'name/value'
# Mock the actual ... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_delete_service_account_field_headers_async():
| 69 | 69 | 233 | 15 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_field_headers_async | test_delete_service_account_field_headers_async | 1,831 | 1,860 | 1,831 | 1,832 | e99e921e8871e4d462114de61b4d5143fe257713 | bigcode/the-stack | train |
48fb27e51e0511c9399f16fd | train | function | def test_create_role_field_headers():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.CreateRoleRequest()
request.parent = 'parent/val... | def test_create_role_field_headers():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.CreateRoleRequest()
request.parent = 'parent/value'
# Mock the actual call within... | _permissions_value']
assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
@pytest.mark.asyncio
async def test_create_role_async_from_dict():
await test_create_role_async(request_type=dict)
def test_create_role_field_headers():
| 65 | 65 | 218 | 7 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_role_field_headers | test_create_role_field_headers | 5,686 | 5,714 | 5,686 | 5,686 | 873e1c22ca791febac47d026a95c71f073d8ddcb | bigcode/the-stack | train |
59e0e60d9c0995fa818fc20a | train | function | @pytest.mark.asyncio
async def test_enable_service_account_async_from_dict():
await test_enable_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_enable_service_account_async_from_dict():
| await test_enable_service_account_async(request_type=dict)
| len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == iam.EnableServiceAccountRequest()
# Establish that the response is the type that we expect.
assert response is None
@pytest.mark.asyncio
async def test_enable_service_account_async_from_dict():
| 64 | 64 | 26 | 15 | 48 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_enable_service_account_async_from_dict | test_enable_service_account_async_from_dict | 2,167 | 2,169 | 2,167 | 2,168 | 220b44dd5f98c8abb76e4c3182b6cadd66ffcb7e | bigcode/the-stack | train |
8f64f1d31f87efbab311b93a | train | function | @pytest.mark.asyncio
async def test_sign_jwt_async(transport: str = 'grpc_asyncio', request_type=iam.SignJwtRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
... | @pytest.mark.asyncio
async def test_sign_jwt_async(transport: str = 'grpc_asyncio', request_type=iam.SignJwtRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | mock.patch.object(
type(client.transport.sign_jwt),
'__call__') as call:
client.sign_jwt()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.SignJwtRequest()
@pytest.mark.asyncio
async def test_sign_jwt_async(transport: str = 'grpc_asynci... | 85 | 85 | 285 | 30 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_async | test_sign_jwt_async | 3,836 | 3,866 | 3,836 | 3,837 | e5514cf16b5d2903a62adcafd62195d99b480d4b | bigcode/the-stack | train |
7f306f65311c4275df3432d3 | train | function | def test_parse_common_billing_account_path():
expected = {
"billing_account": "abalone",
}
path = IAMClient.common_billing_account_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_billing_account_path(path)
assert expected == actual
| def test_parse_common_billing_account_path():
| expected = {
"billing_account": "abalone",
}
path = IAMClient.common_billing_account_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_billing_account_path(path)
assert expected == actual
| test_common_billing_account_path():
billing_account = "scallop"
expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, )
actual = IAMClient.common_billing_account_path(billing_account)
assert expected == actual
def test_parse_common_billing_account_path():
| 64 | 64 | 66 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_parse_common_billing_account_path | test_parse_common_billing_account_path | 7,210 | 7,218 | 7,210 | 7,210 | fbfbc072cad241e0a4fdcf0fbf1a4fe5d5a55b2d | bigcode/the-stack | train |
32ac786ff6c3351f066467a1 | train | function | def test_get_service_account(transport: str = 'grpc', request_type=iam.GetServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out... | def test_get_service_account(transport: str = 'grpc', request_type=iam.GetServiceAccountRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | _token='ghi',
),
iam.ListServiceAccountsResponse(
accounts=[
iam.ServiceAccount(),
iam.ServiceAccount(),
],
),
RuntimeError,
)
pages = []
async for page_ in (await client.list_... | 115 | 115 | 385 | 22 | 92 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account | test_get_service_account | 814 | 857 | 814 | 814 | 655c679a29ffde77813155aca1d481408d591df8 | bigcode/the-stack | train |
71941fcada6423f0e29e02eb | train | function | @pytest.mark.asyncio
async def test_get_service_account_flattened_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_accou... | @pytest.mark.asyncio
async def test_get_service_account_flattened_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_account),
'__call__') as call:
# Designate an appropriate re... | ing to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.get_service_account(
iam.GetServiceAccountRequest(),
name='name_value',
)
@pytest.mark.asyncio
async def test_get_service_account_flattened_async():
| 64 | 64 | 204 | 16 | 48 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_flattened_async | test_get_service_account_flattened_async | 1,035 | 1,059 | 1,035 | 1,036 | c029140690a66867b9f55be4ab2ea7a05e88cc43 | bigcode/the-stack | train |
bcd2625c4fb3def6a8948594 | train | function | def test_parse_common_project_path():
expected = {
"project": "nudibranch",
}
path = IAMClient.common_project_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_project_path(path)
assert expected == actual
| def test_parse_common_project_path():
| expected = {
"project": "nudibranch",
}
path = IAMClient.common_project_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_project_path(path)
assert expected == actual
| Client.parse_common_organization_path(path)
assert expected == actual
def test_common_project_path():
project = "oyster"
expected = "projects/{project}".format(project=project, )
actual = IAMClient.common_project_path(project)
assert expected == actual
def test_parse_common_project_path():
| 64 | 64 | 60 | 7 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_parse_common_project_path | test_parse_common_project_path | 7,261 | 7,269 | 7,261 | 7,261 | 483e2f43c04c6c25e2c2a60ef94ce82d6c2b52d9 | bigcode/the-stack | train |
5a734d4aa73bf8577232abe9 | train | function | @pytest.mark.asyncio
async def test_get_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.GetIamPolicyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the run... | @pytest.mark.asyncio
async def test_get_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.GetIamPolicyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | _policy),
'__call__') as call:
client.get_iam_policy()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam_policy_pb2.GetIamPolicyRequest()
@pytest.mark.asyncio
async def test_get_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy... | 85 | 85 | 284 | 35 | 50 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_async | test_get_iam_policy_async | 4,077 | 4,107 | 4,077 | 4,078 | 0bd46b5abd4e803a50b2e993ca7b45631651a1a7 | bigcode/the-stack | train |
6284988d7bcf0a9b1cea066d | train | function | def test_iam_host_no_port():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(api_endpoint='iam.googleapis.com'),
)
assert client.transport._host == 'iam.googleapis.com:443'
| def test_iam_host_no_port():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(api_endpoint='iam.googleapis.com'),
)
assert client.transport._host == 'iam.googleapis.com:443'
| =cred,
client_cert_source_for_mtls=client_cert_source_callback
)
expected_cert, expected_key = client_cert_source_callback()
mock_ssl_cred.assert_called_once_with(
certificate_chain=expected_cert,
private_key=expected_key
)
... | 64 | 64 | 54 | 8 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_host_no_port | test_iam_host_no_port | 7,038 | 7,043 | 7,038 | 7,038 | b9033489625aa337b0e22d878c82c340555d498b | bigcode/the-stack | train |
c57a1c50b575b3e79bca0706 | train | function | @pytest.mark.asyncio
async def test_undelete_service_account_async_from_dict():
await test_undelete_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_undelete_service_account_async_from_dict():
| await test_undelete_service_account_async(request_type=dict)
| call.mock_calls[0]
assert args[0] == iam.UndeleteServiceAccountRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.UndeleteServiceAccountResponse)
@pytest.mark.asyncio
async def test_undelete_service_account_async_from_dict():
| 64 | 64 | 30 | 17 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_service_account_async_from_dict | test_undelete_service_account_async_from_dict | 2,022 | 2,024 | 2,022 | 2,023 | ab26e02976945e93f36af3928f6ca380a319a0c9 | bigcode/the-stack | train |
58ac6145e25e71c6857509ef | train | function | @pytest.mark.asyncio
async def test_query_testable_permissions_async_from_dict():
await test_query_testable_permissions_async(request_type=dict)
| @pytest.mark.asyncio
async def test_query_testable_permissions_async_from_dict():
| await test_query_testable_permissions_async(request_type=dict)
| == iam.QueryTestablePermissionsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.QueryTestablePermissionsAsyncPager)
assert response.next_page_token == 'next_page_token_value'
@pytest.mark.asyncio
async def test_query_testable_permissions_async_from_dic... | 64 | 64 | 28 | 16 | 48 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_testable_permissions_async_from_dict | test_query_testable_permissions_async_from_dict | 6,357 | 6,359 | 6,357 | 6,358 | d644854c1a1cc2a3d2cb970e3f6cf37bf16fc1c5 | bigcode/the-stack | train |
880632690c63c8c1b9512990 | train | function | def test_undelete_role_field_headers():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UndeleteRoleRequest()
request.name = 'name/val... | def test_undelete_role_field_headers():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UndeleteRoleRequest()
request.name = 'name/value'
# Mock the actual call within t... | assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
@pytest.mark.asyncio
async def test_undelete_role_async_from_dict():
await test_undelete_role_async(request_type=dict)
def test_undelete_role_field_headers():
| 67 | 67 | 225 | 9 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_role_field_headers | test_undelete_role_field_headers | 6,211 | 6,239 | 6,211 | 6,211 | e4c1adfb932f8cd868d0c215d5504bcb46f0bcd6 | bigcode/the-stack | train |
9b5e27b002598daf29a94187 | train | function | def test_query_grantable_roles_from_dict():
test_query_grantable_roles(request_type=dict)
| def test_query_grantable_roles_from_dict():
| test_query_grantable_roles(request_type=dict)
| ]
assert args[0] == iam.QueryGrantableRolesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.QueryGrantableRolesPager)
assert response.next_page_token == 'next_page_token_value'
def test_query_grantable_roles_from_dict():
| 64 | 64 | 21 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_from_dict | test_query_grantable_roles_from_dict | 4,811 | 4,812 | 4,811 | 4,811 | 292f136fd799080fb2fe7f966a854e22523e36e6 | bigcode/the-stack | train |
9bd86c278ff4072909a5bc1d | train | function | @pytest.mark.asyncio
async def test_undelete_role_async(transport: str = 'grpc_asyncio', request_type=iam.UndeleteRoleRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is conc... | @pytest.mark.asyncio
async def test_undelete_role_async(transport: str = 'grpc_asyncio', request_type=iam.UndeleteRoleRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.undelete_role),
'__call__') as call:
client.undelete_role()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.UndeleteRoleR... | 109 | 109 | 364 | 33 | 76 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_role_async | test_undelete_role_async | 6,163 | 6,203 | 6,163 | 6,164 | 34fe300a6a4a1d3df4542412a5bf3a8aa43bb965 | bigcode/the-stack | train |
01bcff6506bfb6d45a949ea7 | train | function | def test_disable_service_account(transport: str = 'grpc', request_type=iam.DisableServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are moc... | def test_disable_service_account(transport: str = 'grpc', request_type=iam.DisableServiceAccountRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
def test_disable_service_account(transport: str = 'grpc', request_type=iam.DisableServiceAccountRequest):
| 65 | 65 | 219 | 22 | 43 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_disable_service_account | test_disable_service_account | 2,235 | 2,259 | 2,235 | 2,235 | aa22bf34c1418485c468221fb60762047bbb85e6 | bigcode/the-stack | train |
a74734cbdbb5771bd420b3f0 | train | function | @pytest.mark.asyncio
async def test_create_role_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.CreateRoleReque... | @pytest.mark.asyncio
async def test_create_role_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.CreateRoleRequest()
request.parent = 'parent/value'
# Mock the actual call w... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'parent=parent/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_create_role_field_headers_async():
| 69 | 69 | 232 | 14 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_role_field_headers_async | test_create_role_field_headers_async | 5,717 | 5,746 | 5,717 | 5,718 | b47a6d91bc3c466ac15131b11ee181fcd63c3dd0 | bigcode/the-stack | train |
409ff854d46e1a1e18030401 | train | function | def test_get_iam_policy_flattened():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_iam_policy),
'__call__') as call:
# ... | def test_get_iam_policy_flattened():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_iam_policy),
'__call__') as call:
# Designate an appropriate return value... | call.return_value = policy_pb2.Policy()
response = client.get_iam_policy(request={
'resource': 'resource_value',
'options': options_pb2.GetPolicyOptions(requested_policy_version=2598),
}
)
call.assert_called()
def test_get_iam_policy_flattened():
| 64 | 64 | 183 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_flattened | test_get_iam_policy_flattened | 4,195 | 4,216 | 4,195 | 4,195 | 20cfaaf91195f5eef9f912bf71af9cde8f21e383 | bigcode/the-stack | train |
6bd69b114e600b40726e36c5 | train | function | def test_list_service_account_keys_field_headers():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.ListServiceAccountKeysRequest()
re... | def test_list_service_account_keys_field_headers():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.ListServiceAccountKeysRequest()
request.name = 'name/value'
# Mock the actual cal... | .ListServiceAccountKeysRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.ListServiceAccountKeysResponse)
@pytest.mark.asyncio
async def test_list_service_account_keys_async_from_dict():
await test_list_service_account_keys_async(request_type=dict)
def tes... | 68 | 68 | 229 | 9 | 59 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_account_keys_field_headers | test_list_service_account_keys_field_headers | 2,464 | 2,492 | 2,464 | 2,464 | 2b094e74159c7c9a8e028dfb2f7a002264c412c1 | bigcode/the-stack | train |
28e1c215028f3484178530ad | train | function | def test_lint_policy(transport: str = 'grpc', request_type=iam.LintPolicyRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API... | def test_lint_policy(transport: str = 'grpc', request_type=iam.LintPolicyRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | type that we expect.
assert isinstance(response, iam.QueryAuditableServicesResponse)
@pytest.mark.asyncio
async def test_query_auditable_services_async_from_dict():
await test_query_auditable_services_async(request_type=dict)
def test_lint_policy(transport: str = 'grpc', request_type=iam.LintPolicyRequest):
| 69 | 69 | 230 | 22 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_lint_policy | test_lint_policy | 6,627 | 6,652 | 6,627 | 6,627 | 8400f11e2ef14c137aa44b6e444d9ef488cfbc7c | bigcode/the-stack | train |
5bf747e9bc4d5e16cc849705 | train | function | def test_delete_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call... | def test_delete_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.delete_role),
'__call__') as call:
client.delete_ro... | _blob'
assert response.deleted is True
def test_delete_role_from_dict():
test_delete_role(request_type=dict)
def test_delete_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 134 | 40 | 24 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_role_empty_call | test_delete_role_empty_call | 5,970 | 5,985 | 5,970 | 5,972 | 4e24ebbf0602c7b771c52a9ea4b847478c7a2ac2 | bigcode/the-stack | train |
b4719fdf6e7ba3e7a5953504 | train | function | @pytest.mark.asyncio
async def test_test_iam_permissions_flattened_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.test_iam_permiss... | @pytest.mark.asyncio
async def test_test_iam_permissions_flattened_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.test_iam_permissions),
'__call__') as call:
# Designate an appropriate r... | with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.test_iam_permissions(
iam_policy_pb2.TestIamPermissionsRequest(),
resource='resource_value',
permissions=['permissions_value'],
)
@pytest.mark.asyncio
async ... | 70 | 70 | 235 | 17 | 53 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions_flattened_async | test_test_iam_permissions_flattened_async | 4,736 | 4,762 | 4,736 | 4,737 | 5e959ccaafa358be2917b79065a742a9c4fcfe37 | bigcode/the-stack | train |
88c022d51399932ae141ae6f | train | function | @pytest.mark.asyncio
async def test_list_service_accounts_async_from_dict():
await test_list_service_accounts_async(request_type=dict)
| @pytest.mark.asyncio
async def test_list_service_accounts_async_from_dict():
| await test_list_service_accounts_async(request_type=dict)
| [0] == iam.ListServiceAccountsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListServiceAccountsAsyncPager)
assert response.next_page_token == 'next_page_token_value'
@pytest.mark.asyncio
async def test_list_service_accounts_async_from_dict():
| 64 | 64 | 26 | 15 | 49 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_accounts_async_from_dict | test_list_service_accounts_async_from_dict | 480 | 482 | 480 | 481 | 828261d870b1789fb210d2ef1c607e212566e134 | bigcode/the-stack | train |
e92073559ee2d6a2a58238b3 | train | function | @pytest.mark.asyncio
async def test_transport_close_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport="grpc_asyncio",
)
with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close:
async with client:
... | @pytest.mark.asyncio
async def test_transport_close_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport="grpc_asyncio",
)
with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close:
async with client:
close.assert_not_called()
close.assert_called_once... | '_prep_wrapped_messages') as prep:
transport_class = IAMClient.get_transport_class()
transport = transport_class(
credentials=ga_credentials.AnonymousCredentials(),
client_info=client_info,
)
prep.assert_called_once_with(client_info)
@pytest.mark.asyncio
async de... | 64 | 64 | 75 | 12 | 52 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_transport_close_async | test_transport_close_async | 7,310 | 7,319 | 7,310 | 7,311 | d51d78c37b214b332c8292340bb2121207101061 | bigcode/the-stack | train |
afe0d85d5e1b63e703cb1447 | train | function | def test_query_grantable_roles_pages():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials,
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.query_grantable_roles),
'__call__') as call:
... | def test_query_grantable_roles_pages():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials,
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.query_grantable_roles),
'__call__') as call:
# Set the response to a series of ... | Error,
)
metadata = ()
pager = client.query_grantable_roles(request={})
assert pager._metadata == metadata
results = [i for i in pager]
assert len(results) == 6
assert all(isinstance(i, iam.Role)
for i in results)
def test_query_grantable_rol... | 72 | 72 | 240 | 9 | 63 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_pages | test_query_grantable_roles_pages | 4,997 | 5,036 | 4,997 | 4,997 | 93bc64e05af1e2e757234ddec7b2731cd438e4b8 | bigcode/the-stack | train |
9b2ad37367f654fdb84fb30e | train | function | @pytest.mark.parametrize("transport_class,transport_name", [
(transports.IAMGrpcTransport, "grpc"),
(transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_service_account_always_use_jwt(transport_class, transport_name):
with mock.patch.object(service_account.Credentials, 'with_always_u... | @pytest.mark.parametrize("transport_class,transport_name", [
(transports.IAMGrpcTransport, "grpc"),
(transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_service_account_always_use_jwt(transport_class, transport_name):
| with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt:
creds = service_account.Credentials(None, None, None)
transport = transport_class(credentials=creds, always_use_jwt_access=True)
use_jwt.assert_called_once_with(True)
with mock.pat... | .googleapis.com:443'
@pytest.mark.parametrize("transport_class,transport_name", [
(transports.IAMGrpcTransport, "grpc"),
(transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_service_account_always_use_jwt(transport_class, transport_name):
| 64 | 64 | 191 | 59 | 5 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_service_account_always_use_jwt | test_iam_client_service_account_always_use_jwt | 106 | 119 | 106 | 110 | 74eb0d0a09c6216fc2827eee2efb2336c5fca232 | bigcode/the-stack | train |
fce073ecfe00aa854d5bf428 | train | function | @pytest.mark.asyncio
async def test_update_service_account_async_from_dict():
await test_update_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_update_service_account_async_from_dict():
| await test_update_service_account_async(request_type=dict)
| _name == 'display_name_value'
assert response.etag == b'etag_blob'
assert response.description == 'description_value'
assert response.oauth2_client_id == 'oauth2_client_id_value'
assert response.disabled is True
@pytest.mark.asyncio
async def test_update_service_account_async_from_dict():
| 64 | 64 | 26 | 15 | 48 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_service_account_async_from_dict | test_update_service_account_async_from_dict | 1,467 | 1,469 | 1,467 | 1,468 | ce1adac1c643a7ad1cb43858a03c6bf13a828b8f | bigcode/the-stack | train |
4cd70640a6cf2db2ca160f77 | train | function | @pytest.mark.asyncio
async def test_upload_service_account_key_async_from_dict():
await test_upload_service_account_key_async(request_type=dict)
| @pytest.mark.asyncio
async def test_upload_service_account_key_async_from_dict():
| await test_upload_service_account_key_async(request_type=dict)
| assert response.public_key_data == b'public_key_data_blob'
assert response.key_origin == iam.ServiceAccountKeyOrigin.USER_PROVIDED
assert response.key_type == iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED
@pytest.mark.asyncio
async def test_upload_service_account_key_async_from_dict():
| 64 | 64 | 28 | 16 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_upload_service_account_key_async_from_dict | test_upload_service_account_key_async_from_dict | 3,248 | 3,250 | 3,248 | 3,249 | f564de9b9663aa152b149d58c51d93fa96e2fc8d | bigcode/the-stack | train |
b56372d7e4ffb65a84727508 | train | function | @pytest.mark.parametrize(
"transport_class",
[
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
],
)
@requires_google_auth_gte_1_25_0
def test_iam_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC cre... | @pytest.mark.parametrize(
"transport_class",
[
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
],
)
@requires_google_auth_gte_1_25_0
def test_iam_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC cre... | with mock.patch.object(google.auth, 'default', autospec=True) as adc:
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport_class(quota_project_id="octopus", scopes=["1", "2"])
adc.assert_called_once_with(
scopes=["1", "2"],
default_scopes=( ... | @pytest.mark.parametrize(
"transport_class",
[
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
],
)
@requires_google_auth_gte_1_25_0
def test_iam_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC cre... | 75 | 64 | 168 | 75 | 0 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_transport_auth_adc | test_iam_transport_auth_adc | 6,916 | 6,934 | 6,916 | 6,926 | 6c76d6533d0ffbac929181a06019bf17f9f38a02 | bigcode/the-stack | train |
2f4e38c0529483735b1aa81d | train | function | def test_update_role(transport: str = 'grpc', request_type=iam.UpdateRoleRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API... | def test_update_role(transport: str = 'grpc', request_type=iam.UpdateRoleRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | RPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'parent=parent/value',
) in kw['metadata'... | 101 | 101 | 338 | 20 | 81 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_role | test_update_role | 5,749 | 5,788 | 5,749 | 5,749 | 9703f95debf3e050c5f8fd996ad6bb334598a750 | bigcode/the-stack | train |
310f7bbb62d221819b4742b0 | train | function | def test_undelete_service_account(transport: str = 'grpc', request_type=iam.UndeleteServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are m... | def test_undelete_service_account(transport: str = 'grpc', request_type=iam.UndeleteServiceAccountRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.delete_service_account(
iam.DeleteServiceAccountRequest(),
name='name_value',
)
def test_undelete_service_account(transport: str = 'grpc', request_ty... | 73 | 73 | 244 | 26 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_service_account | test_undelete_service_account | 1,943 | 1,968 | 1,943 | 1,943 | ef4f7fdbdae83bb5c62358ac1b1a79105c8b85f5 | bigcode/the-stack | train |
eacd5d7fb1dec426df9c5baa | train | function | @pytest.mark.asyncio
async def test_create_service_account_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.Crea... | @pytest.mark.asyncio
async def test_create_service_account_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.CreateServiceAccountRequest()
request.name = 'name/value'
# Mock the actual ... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_create_service_account_field_headers_async():
| 70 | 70 | 236 | 15 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_field_headers_async | test_create_service_account_field_headers_async | 1,228 | 1,257 | 1,228 | 1,229 | 39167d976c9bda0d717be9e86e7a20273bd4830e | bigcode/the-stack | train |
dd83d30660b3c372701bdb84 | train | function | def test_delete_service_account_key_from_dict():
test_delete_service_account_key(request_type=dict)
| def test_delete_service_account_key_from_dict():
| test_delete_service_account_key(request_type=dict)
| assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0] == iam.DeleteServiceAccountKeyRequest()
# Establish that the response is the type that we expect.
assert response is None
def test_delete_service_account_key_from_dict():
| 64 | 64 | 19 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_key_from_dict | test_delete_service_account_key_from_dict | 3,343 | 3,344 | 3,343 | 3,343 | 7ddd70abc36ec971d208f9489adb1378668d097c | bigcode/the-stack | train |
622c587f9376064cc2e75e02 | train | function | def test_set_iam_policy_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.set_iam_policy(
iam_pol... | def test_set_iam_policy_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.set_iam_policy(
iam_policy_pb2.SetIamPolicyRequest(),
... | # Establish that the underlying call was made with the expected
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].resource == 'resource_value'
def test_set_iam_policy_flattened_error():
| 64 | 64 | 83 | 11 | 53 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_flattened_error | test_set_iam_policy_flattened_error | 4,471 | 4,482 | 4,471 | 4,471 | c7cb100d3fb068da84b061ade63e52cbb86f41c5 | bigcode/the-stack | train |
727528a8e82e199163ea6b7c | train | function | def test_update_role_field_headers():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UpdateRoleRequest()
request.name = 'name/value'
... | def test_update_role_field_headers():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UpdateRoleRequest()
request.name = 'name/value'
# Mock the actual call within the... | _permissions_value']
assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
@pytest.mark.asyncio
async def test_update_role_async_from_dict():
await test_update_role_async(request_type=dict)
def test_update_role_field_headers():
| 65 | 65 | 217 | 7 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_role_field_headers | test_update_role_field_headers | 5,861 | 5,889 | 5,861 | 5,861 | 2fef219cbafde4f7980849fd14846cf34e93e863 | bigcode/the-stack | train |
72f74a52ed446700b1023197 | train | function | def test_parse_key_path():
expected = {
"project": "octopus",
"service_account": "oyster",
"key": "nudibranch",
}
path = IAMClient.key_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_key_path(path)
assert expected == actual
| def test_parse_key_path():
| expected = {
"project": "octopus",
"service_account": "oyster",
"key": "nudibranch",
}
path = IAMClient.key_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_key_path(path)
assert expected == actual
| "whelk"
expected = "projects/{project}/serviceAccounts/{service_account}/keys/{key}".format(project=project, service_account=service_account, key=key, )
actual = IAMClient.key_path(project, service_account, key)
assert expected == actual
def test_parse_key_path():
| 64 | 64 | 74 | 6 | 57 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_parse_key_path | test_parse_key_path | 7,172 | 7,182 | 7,172 | 7,172 | 96c28b346c1e82ae412e76957a6d6526d13a3a8f | bigcode/the-stack | train |
a285c17775e681074a518006 | train | function | def test_iam_grpc_transport_channel():
channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials())
# Check that channel is used if provided.
transport = transports.IAMGrpcTransport(
host="squid.clam.whelk",
channel=channel,
)
assert transport.grpc_channel ==... | def test_iam_grpc_transport_channel():
| channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials())
# Check that channel is used if provided.
transport = transports.IAMGrpcTransport(
host="squid.clam.whelk",
channel=channel,
)
assert transport.grpc_channel == channel
assert transport._host == ... | iam_host_with_port():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(api_endpoint='iam.googleapis.com:8000'),
)
assert client.transport._host == 'iam.googleapis.com:8000'
def test_iam_grpc_transport_channel():
| 64 | 64 | 98 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_grpc_transport_channel | test_iam_grpc_transport_channel | 7,053 | 7,063 | 7,053 | 7,053 | 1899fbc106ebbb43caca336d7ab145b8b585df0c | bigcode/the-stack | train |
85fbb7723de4465afeaadee0 | train | function | @pytest.mark.asyncio
async def test_delete_service_account_flattened_error_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
... | @pytest.mark.asyncio
async def test_delete_service_account_flattened_error_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.delete_service_account(
iam.DeleteServiceAccountRequest... | that the underlying call was made with the expected
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
@pytest.mark.asyncio
async def test_delete_service_account_flattened_error_async():
| 64 | 64 | 87 | 17 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_flattened_error_async | test_delete_service_account_flattened_error_async | 1,928 | 1,940 | 1,928 | 1,929 | 9cbeb3192782f1ed746c459a12b3aef51a20389f | bigcode/the-stack | train |
32d77c1f6d5590904ad7c93d | train | function | def test_get_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the... | def test_get_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_account_key),
'__call__') as call:
clie... | _MANAGED
def test_get_service_account_key_from_dict():
test_get_service_account_key(request_type=dict)
def test_get_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 142 | 42 | 22 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_key_empty_call | test_get_service_account_key_empty_call | 2,659 | 2,674 | 2,659 | 2,661 | dc3196fb038bd8f34ffaa378c2c573224c408135 | bigcode/the-stack | train |
d63c762f68770bc4aa19aee8 | train | function | def test_transport_close():
transports = {
"grpc": "_grpc_channel",
}
for transport, close_name in transports.items():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport
)
with mock.patch.object(type(getattr(cli... | def test_transport_close():
| transports = {
"grpc": "_grpc_channel",
}
for transport, close_name in transports.items():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport
)
with mock.patch.object(type(getattr(client.transport, close_name)),... | AsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport="grpc_asyncio",
)
with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close:
async with client:
close.assert_not_called()
close.assert_called_once()
def test_tran... | 64 | 64 | 87 | 5 | 59 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_transport_close | test_transport_close | 7,321 | 7,334 | 7,321 | 7,321 | 1c48fa5fe0f9e62bf0e76aa2af234b569098ca11 | bigcode/the-stack | train |
4eaaad07ea2d3f2f5152d973 | train | function | @pytest.mark.asyncio
async def test_delete_role_async_from_dict():
await test_delete_role_async(request_type=dict)
| @pytest.mark.asyncio
async def test_delete_role_async_from_dict():
| await test_delete_role_async(request_type=dict)
| response.description == 'description_value'
assert response.included_permissions == ['included_permissions_value']
assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
@pytest.mark.asyncio
async def test_delete_role_async_from_dict(... | 64 | 64 | 24 | 14 | 49 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_role_async_from_dict | test_delete_role_async_from_dict | 6,031 | 6,033 | 6,031 | 6,032 | a2c37138478f3ed94bfee863e6618e1702e4f0dd | bigcode/the-stack | train |
4302139fdba292cc603422b4 | train | function | def test_set_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual c... | def test_set_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.set_iam_policy),
'__call__') as call:
client.set_ia... | ag_blob'
def test_set_iam_policy_from_dict():
test_set_iam_policy(request_type=dict)
def test_set_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 144 | 42 | 22 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_empty_call | test_set_iam_policy_empty_call | 4,311 | 4,326 | 4,311 | 4,313 | f66028473ae4130ec59b7bea8eca93515eac9332 | bigcode/the-stack | train |
46d2d0034fc7758b0bc64baf | train | function | def test_list_service_account_keys_from_dict():
test_list_service_account_keys(request_type=dict)
| def test_list_service_account_keys_from_dict():
| test_list_service_account_keys(request_type=dict)
| == 1
_, args, _ = call.mock_calls[0]
assert args[0] == iam.ListServiceAccountKeysRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.ListServiceAccountKeysResponse)
def test_list_service_account_keys_from_dict():
| 64 | 64 | 19 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_account_keys_from_dict | test_list_service_account_keys_from_dict | 2,408 | 2,409 | 2,408 | 2,408 | d0cd4f9eee23aad69c345cb6be09212f5c7a2df4 | bigcode/the-stack | train |
9bb35969700f03e3a08b0e2f | train | function | def test_get_service_account_key_from_dict():
test_get_service_account_key(request_type=dict)
| def test_get_service_account_key_from_dict():
| test_get_service_account_key(request_type=dict)
| b'private_key_data_blob'
assert response.public_key_data == b'public_key_data_blob'
assert response.key_origin == iam.ServiceAccountKeyOrigin.USER_PROVIDED
assert response.key_type == iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED
def test_get_service_account_key_from_dict():
| 64 | 64 | 19 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_key_from_dict | test_get_service_account_key_from_dict | 2,655 | 2,656 | 2,655 | 2,655 | c9c9b5759611e82f54c552d93e9efcaa6fbf685a | bigcode/the-stack | train |
659bb74d941ccee4bc939356 | train | function | def test_patch_service_account(transport: str = 'grpc', request_type=iam.PatchServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking... | def test_patch_service_account(transport: str = 'grpc', request_type=iam.PatchServiceAccountRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | client.update_service_account(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
... | 116 | 116 | 387 | 23 | 93 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_patch_service_account | test_patch_service_account | 1,535 | 1,578 | 1,535 | 1,535 | e207ea3d3f999a2c06f64fe74603f408ad31f29e | bigcode/the-stack | train |
c363bff8123346ffb5831c9b | train | function | def test_get_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual c... | def test_get_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_iam_policy),
'__call__') as call:
client.get_ia... | ag_blob'
def test_get_iam_policy_from_dict():
test_get_iam_policy(request_type=dict)
def test_get_iam_policy_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 144 | 42 | 22 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_empty_call | test_get_iam_policy_empty_call | 4,059 | 4,074 | 4,059 | 4,061 | 7de8ff90fc1007beb5c9234601ee477ea4b353b1 | bigcode/the-stack | train |
b6c0f19cbf410e18e4befa47 | train | function | @pytest.mark.asyncio
async def test_undelete_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.UndeleteServiceAccountRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far a... | @pytest.mark.asyncio
async def test_undelete_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.UndeleteServiceAccountRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | as call:
client.undelete_service_account()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.UndeleteServiceAccountRequest()
@pytest.mark.asyncio
async def test_undelete_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.UndeleteServiceAccou... | 78 | 78 | 260 | 35 | 43 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_service_account_async | test_undelete_service_account_async | 1,993 | 2,019 | 1,993 | 1,994 | 604e32b273dd0478e317e922d5aa229e475227f2 | bigcode/the-stack | train |
a77fb925494d3ca32951ca59 | train | function | @pytest.mark.asyncio
async def test_get_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.GetServiceAccountKeyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as t... | @pytest.mark.asyncio
async def test_get_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.GetServiceAccountKeyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_service_account_key),
'__call__') as call:
... | 135 | 135 | 450 | 33 | 102 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_key_async | test_get_service_account_key_async | 2,677 | 2,717 | 2,677 | 2,678 | f582a5bff1251d2a5cb02b45fffd321521d1b239 | bigcode/the-stack | train |
94c258e5b38273e2874cf3f4 | train | function | def test_undelete_role_from_dict():
test_undelete_role(request_type=dict)
| def test_undelete_role_from_dict():
| test_undelete_role(request_type=dict)
| title_value'
assert response.description == 'description_value'
assert response.included_permissions == ['included_permissions_value']
assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
def test_undelete_role_from_dict():
| 64 | 64 | 19 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_role_from_dict | test_undelete_role_from_dict | 6,141 | 6,142 | 6,141 | 6,141 | 1376a4268ab488223d0c3a5794fe22bde58b521b | bigcode/the-stack | train |
d2f442eb225c0badba9537e8 | train | function | def test_query_auditable_services_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock th... | def test_query_auditable_services_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.query_auditable_services),
'__call__') as call:
cli... | def test_query_auditable_services_from_dict():
test_query_auditable_services(request_type=dict)
def test_query_auditable_services_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 145 | 43 | 21 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_auditable_services_empty_call | test_query_auditable_services_empty_call | 6,575 | 6,590 | 6,575 | 6,577 | 1be13ae7fcd65bef4db88b315dcdbd8e64c70f80 | bigcode/the-stack | train |
b093185d77d599980ce0f266 | train | function | @pytest.mark.asyncio
async def test_update_role_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UpdateRoleReque... | @pytest.mark.asyncio
async def test_update_role_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.UpdateRoleRequest()
request.name = 'name/value'
# Mock the actual call withi... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_update_role_field_headers_async():
| 69 | 69 | 231 | 14 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_role_field_headers_async | test_update_role_field_headers_async | 5,892 | 5,921 | 5,892 | 5,893 | 6889bfb2966d3db75d70f25a7a56111dbb9943f7 | bigcode/the-stack | train |
4d017da8ee93e61705062f53 | train | function | def test_sign_blob_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.sign_blob(
iam.SignBlobReque... | def test_sign_blob_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.sign_blob(
iam.SignBlobRequest(),
name='name_value',
... | object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
assert args[0].bytes_to_sign == b'bytes_to_sign_blob'
def test_sign_blob_flattened_error():
| 64 | 64 | 86 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_blob_flattened_error | test_sign_blob_flattened_error | 3,722 | 3,734 | 3,722 | 3,722 | 616c518b202dcf822b9e5f67e6b356bc3d8601cf | bigcode/the-stack | train |
fa1749f0a22386698b71b36e | train | function | def test_create_service_account_key_flattened():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.create_service_account_key),
'__call... | def test_create_service_account_key_flattened():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.create_service_account_key),
'__call__') as call:
# Designate an appropriate ... | )
_, args, _ = call.mock_calls[0]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
def test_create_service_account_key_flattened():
| 78 | 78 | 261 | 10 | 68 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_key_flattened | test_create_service_account_key_flattened | 3,049 | 3,074 | 3,049 | 3,049 | 98b8ad7221a8d7b0f2d7987a9661ea9f43a8c71f | bigcode/the-stack | train |
f3ef91df335d421df500af19 | train | function | @pytest.mark.asyncio
async def test_query_auditable_services_async_from_dict():
await test_query_auditable_services_async(request_type=dict)
| @pytest.mark.asyncio
async def test_query_auditable_services_async_from_dict():
| await test_query_auditable_services_async(request_type=dict)
| _ = call.mock_calls[0]
assert args[0] == iam.QueryAuditableServicesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.QueryAuditableServicesResponse)
@pytest.mark.asyncio
async def test_query_auditable_services_async_from_dict():
| 64 | 64 | 30 | 17 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_auditable_services_async_from_dict | test_query_auditable_services_async_from_dict | 6,622 | 6,624 | 6,622 | 6,623 | 732d5362f03d85d0cf2947c82d5408b5aa43b3b2 | bigcode/the-stack | train |
151e5d8d5a525a9124e9861f | train | function | def test_get_iam_policy_from_dict():
test_get_iam_policy(request_type=dict)
| def test_get_iam_policy_from_dict():
| test_get_iam_policy(request_type=dict)
| [0] == iam_policy_pb2.GetIamPolicyRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, policy_pb2.Policy)
assert response.version == 774
assert response.etag == b'etag_blob'
def test_get_iam_policy_from_dict():
| 64 | 64 | 19 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_from_dict | test_get_iam_policy_from_dict | 4,055 | 4,056 | 4,055 | 4,055 | a63c209ccab2d48eae08f782b6a8373416c17d9e | bigcode/the-stack | train |
67ae8c63f22f56c163c487ae | train | function | def test_get_iam_policy(transport: str = 'grpc', request_type=iam_policy_pb2.GetIamPolicyRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking ou... | def test_get_iam_policy(transport: str = 'grpc', request_type=iam_policy_pb2.GetIamPolicyRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | ing to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.sign_jwt(
iam.SignJwtRequest(),
name='name_value',
payload='payload_value',
)
def test_get_iam_policy(transport: str = 'grpc', requ... | 80 | 80 | 269 | 26 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy | test_get_iam_policy | 4,023 | 4,052 | 4,023 | 4,023 | 268850f273c7bb2e93ad659047bdc85e78c63124 | bigcode/the-stack | train |
4e308211e3815088a2754eb2 | train | function | @pytest.mark.asyncio
async def test_test_iam_permissions_async_from_dict():
await test_test_iam_permissions_async(request_type=dict)
| @pytest.mark.asyncio
async def test_test_iam_permissions_async_from_dict():
| await test_test_iam_permissions_async(request_type=dict)
| 0] == iam_policy_pb2.TestIamPermissionsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam_policy_pb2.TestIamPermissionsResponse)
assert response.permissions == ['permissions_value']
@pytest.mark.asyncio
async def test_test_iam_permissions_async_from_dict():
| 64 | 64 | 28 | 16 | 48 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions_async_from_dict | test_test_iam_permissions_async_from_dict | 4,610 | 4,612 | 4,610 | 4,611 | ad9f77c80a3665cc81bbac5dcd9450dfaff456c1 | bigcode/the-stack | train |
a69c8eac06756aa486a0fb22 | train | function | def test_set_iam_policy_flattened():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.set_iam_policy),
'__call__') as call:
# ... | def test_set_iam_policy_flattened():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.set_iam_policy),
'__call__') as call:
# Designate an appropriate return value... | value for the call.
call.return_value = policy_pb2.Policy()
response = client.set_iam_policy(request={
'resource': 'resource_value',
'policy': policy_pb2.Policy(version=774),
}
)
call.assert_called()
def test_set_iam_policy_flattened():
| 64 | 64 | 183 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_flattened | test_set_iam_policy_flattened | 4,447 | 4,468 | 4,447 | 4,447 | 29dc13cd715ee57d5fe5e114c0ff29d0de945bed | bigcode/the-stack | train |
b05b391f2a0eb5c056691531 | train | function | def test_enable_service_account_from_dict():
test_enable_service_account(request_type=dict)
| def test_enable_service_account_from_dict():
| test_enable_service_account(request_type=dict)
| .
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0] == iam.EnableServiceAccountRequest()
# Establish that the response is the type that we expect.
assert response is None
def test_enable_service_account_from_dict():
| 64 | 64 | 17 | 8 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_enable_service_account_from_dict | test_enable_service_account_from_dict | 2,117 | 2,118 | 2,117 | 2,117 | 468caed2098257af8fd3f3e7874decac9603f21b | bigcode/the-stack | train |
7f691b63b325fc817c65060d | train | function | def test_delete_role_field_headers():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.DeleteRoleRequest()
request.name = 'name/value'
... | def test_delete_role_field_headers():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.DeleteRoleRequest()
request.name = 'name/value'
# Mock the actual call within the... | _permissions_value']
assert response.stage == iam.Role.RoleLaunchStage.BETA
assert response.etag == b'etag_blob'
assert response.deleted is True
@pytest.mark.asyncio
async def test_delete_role_async_from_dict():
await test_delete_role_async(request_type=dict)
def test_delete_role_field_headers():
| 65 | 65 | 217 | 7 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_role_field_headers | test_delete_role_field_headers | 6,036 | 6,064 | 6,036 | 6,036 | db726f476e53388fa0d2a9f8b2beb1304fe51915 | bigcode/the-stack | train |
e36ecd9569f38f74c3802215 | train | function | @pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_file(client_class):
creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory:
factory.return_value = ... | @pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_file(client_class):
| creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory:
factory.return_value = creds
client = client_class.from_service_account_file("dummy/file/path.json")
assert client.transport._credentials == creds
... | _account.Credentials(None, None, None)
transport = transport_class(credentials=creds, always_use_jwt_access=False)
use_jwt.assert_not_called()
@pytest.mark.parametrize("client_class", [
IAMClient,
IAMAsyncClient,
])
def test_iam_client_from_service_account_file(client_class):
| 64 | 64 | 143 | 30 | 34 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_from_service_account_file | test_iam_client_from_service_account_file | 122 | 138 | 122 | 126 | 99115755397e16dbe28bfafd74cf5eae50178845 | bigcode/the-stack | train |
0ef6eb3493ca7ecafe1336df | train | function | @pytest.mark.asyncio
async def test_upload_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.UploadServiceAccountKeyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as fa... | @pytest.mark.asyncio
async def test_upload_service_account_key_async(transport: str = 'grpc_asyncio', request_type=iam.UploadServiceAccountKeyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.upload_service_account_key),
'__call__') as call:
... | 135 | 135 | 450 | 33 | 102 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_upload_service_account_key_async | test_upload_service_account_key_async | 3,205 | 3,245 | 3,205 | 3,206 | fe6ec581d5c6ddaea254a0833585f5f49ea70163 | bigcode/the-stack | train |
5fd76aa7ae470f40ba2bfa66 | train | function | def test_list_service_accounts(transport: str = 'grpc', request_type=iam.ListServiceAccountsRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking... | def test_list_service_accounts(transport: str = 'grpc', request_type=iam.ListServiceAccountsRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | _file=None,
host="squid.clam.whelk",
scopes=None,
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
always_use_jwt_access=True,
)
def test_list_service_accounts(transport: str = 'grpc'... | 76 | 76 | 254 | 22 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_accounts | test_list_service_accounts | 397 | 424 | 397 | 397 | 577ce493ea3317ea7e522d8455f6eb0c08abf4b1 | bigcode/the-stack | train |
89c3e016c9fcbc21d5686b20 | train | function | def test_sign_jwt_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call wi... | def test_sign_jwt_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.sign_jwt),
'__call__') as call:
client.sign_jwt()
... | 'signed_jwt_value'
def test_sign_jwt_from_dict():
test_sign_jwt(request_type=dict)
def test_sign_jwt_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 137 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_empty_call | test_sign_jwt_empty_call | 3,818 | 3,833 | 3,818 | 3,820 | 7584bf8df37cb5eccebcaf148deaff09e3210fca | bigcode/the-stack | train |
75aed0c063b34034408c1ca7 | train | function | @pytest.mark.asyncio
async def test_update_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.ServiceAccount):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is ... | @pytest.mark.asyncio
async def test_update_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.ServiceAccount):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | (
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.update_service_account),
'__call__') as call:
client.update_service_accou... | 119 | 119 | 397 | 29 | 90 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_service_account_async | test_update_service_account_async | 1,420 | 1,464 | 1,420 | 1,421 | 4ca865e9e8cff45b05c51f414114f4ac7c695db5 | bigcode/the-stack | train |
c8c9999277bf936b40b3224a | train | function | def test_get_service_account_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.get_service_account(
... | def test_get_service_account_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.get_service_account(
iam.GetServiceAccountRequest(),
n... | # Establish that the underlying call was made with the expected
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
def test_get_service_account_flattened_error():
| 64 | 64 | 78 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_service_account_flattened_error | test_get_service_account_flattened_error | 1,021 | 1,032 | 1,021 | 1,021 | 4a520a4ae069e1ac17d0924d36cb3e8cd8f55c44 | bigcode/the-stack | train |
5b94ee473a91d516931d9b7f | train | function | @pytest.mark.asyncio
async def test_query_testable_permissions_async(transport: str = 'grpc_asyncio', request_type=iam.QueryTestablePermissionsRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as f... | @pytest.mark.asyncio
async def test_query_testable_permissions_async(transport: str = 'grpc_asyncio', request_type=iam.QueryTestablePermissionsRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | _testable_permissions),
'__call__') as call:
client.query_testable_permissions()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.QueryTestablePermissionsRequest()
@pytest.mark.asyncio
async def test_query_testable_permissions_async(transport: str = ... | 83 | 83 | 278 | 33 | 50 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_testable_permissions_async | test_query_testable_permissions_async | 6,326 | 6,354 | 6,326 | 6,327 | c1d87a6155c0dcfd6e9b5dc1eedb798d3bab5d42 | bigcode/the-stack | train |
bb99b7cd509b938880152aae | train | function | @pytest.mark.asyncio
async def test_lint_policy_async(transport: str = 'grpc_asyncio', request_type=iam.LintPolicyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerne... | @pytest.mark.asyncio
async def test_lint_policy_async(transport: str = 'grpc_asyncio', request_type=iam.LintPolicyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | call__') as call:
client.lint_policy()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.LintPolicyRequest()
@pytest.mark.asyncio
async def test_lint_policy_async(transport: str = 'grpc_asyncio', request_type=iam.LintPolicyRequest):
| 73 | 73 | 246 | 31 | 42 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_lint_policy_async | test_lint_policy_async | 6,677 | 6,703 | 6,677 | 6,678 | 8e6e177d7b64f54fa08938fedf61cc690d8a4363 | bigcode/the-stack | train |
2bfb8e3e1df8e1456732c159 | train | function | @pytest.mark.asyncio
async def test_query_auditable_services_async(transport: str = 'grpc_asyncio', request_type=iam.QueryAuditableServicesRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far a... | @pytest.mark.asyncio
async def test_query_auditable_services_async(transport: str = 'grpc_asyncio', request_type=iam.QueryAuditableServicesRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | as call:
client.query_auditable_services()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.QueryAuditableServicesRequest()
@pytest.mark.asyncio
async def test_query_auditable_services_async(transport: str = 'grpc_asyncio', request_type=iam.QueryAuditableServic... | 76 | 76 | 256 | 34 | 42 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_auditable_services_async | test_query_auditable_services_async | 6,593 | 6,619 | 6,593 | 6,594 | f5234190c998dd92f79bcd2ec6495524c514caa2 | bigcode/the-stack | train |
592ad2e608cb104f3cd00878 | train | function | @pytest.mark.asyncio
async def test_set_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.SetIamPolicyRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the run... | @pytest.mark.asyncio
async def test_set_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy_pb2.SetIamPolicyRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | _policy),
'__call__') as call:
client.set_iam_policy()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam_policy_pb2.SetIamPolicyRequest()
@pytest.mark.asyncio
async def test_set_iam_policy_async(transport: str = 'grpc_asyncio', request_type=iam_policy... | 85 | 85 | 284 | 35 | 50 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_set_iam_policy_async | test_set_iam_policy_async | 4,329 | 4,359 | 4,329 | 4,330 | 3ceb2fc663f5e9d976e1b0b1a6d5d91455c205d3 | bigcode/the-stack | train |
11b4dca8397e9ff59f037096 | train | function | @pytest.mark.asyncio
async def test_query_testable_permissions_async_pager():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials,
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.query_testable_p... | @pytest.mark.asyncio
async def test_query_testable_permissions_async_pager():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials,
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.query_testable_permissions),
'__call__', new_callable=mock.AsyncMock) as call:
... | (
permissions=[
iam.Permission(),
iam.Permission(),
],
),
RuntimeError,
)
pages = list(client.query_testable_permissions(request={}).pages)
for page_, token in zip(pages, ['abc','def','ghi', '']):
... | 83 | 83 | 278 | 16 | 66 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_testable_permissions_async_pager | test_query_testable_permissions_async_pager | 6,451 | 6,497 | 6,451 | 6,452 | 565ad3312b8bc8787888c9c3e2eabcd4ee7bd1e3 | bigcode/the-stack | train |
9c1ccfafef8a97ff5847d634 | train | function | @pytest.mark.asyncio
async def test_test_iam_permissions_flattened_error_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
... | @pytest.mark.asyncio
async def test_test_iam_permissions_flattened_error_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.test_iam_permissions(
iam_policy_pb2.TestIamPermissions... | object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].resource == 'resource_value'
assert args[0].permissions == ['permissions_value']
@pytest.mark.asyncio
async def test_test_iam_permissions_flattened_error_async():
| 64 | 64 | 98 | 18 | 46 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions_flattened_error_async | test_test_iam_permissions_flattened_error_async | 4,765 | 4,778 | 4,765 | 4,766 | e7c22e2458032bd3a196f86f4bdf1fc5e1bf1492 | bigcode/the-stack | train |
51ca8957985d78c65495f071 | train | function | @pytest.mark.asyncio
async def test_get_iam_policy_flattened_error_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
awai... | @pytest.mark.asyncio
async def test_get_iam_policy_flattened_error_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.get_iam_policy(
iam_policy_pb2.GetIamPolicyRequest(),
... | the underlying call was made with the expected
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].resource == 'resource_value'
@pytest.mark.asyncio
async def test_get_iam_policy_flattened_error_async():
| 64 | 64 | 92 | 18 | 46 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_flattened_error_async | test_get_iam_policy_flattened_error_async | 4,260 | 4,272 | 4,260 | 4,261 | f990d8ed926847a40eadcfb1bbc9a555ec79742d | bigcode/the-stack | train |
bf63adc421f9549fbfdc4233 | train | function | def test_delete_service_account_key_flattened_error():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.delete_service_account_... | def test_delete_service_account_key_flattened_error():
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.delete_service_account_key(
iam.DeleteServiceAccountKeyRequest(),
... | # Establish that the underlying call was made with the expected
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
def test_delete_service_account_key_flattened_error():
| 64 | 64 | 81 | 11 | 53 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_key_flattened_error | test_delete_service_account_key_flattened_error | 3,485 | 3,496 | 3,485 | 3,485 | 45c0227a70b6bf135dcc2444d1987a2f87721489 | bigcode/the-stack | train |
8787afc9886474b9176cc2e4 | train | function | @pytest.mark.asyncio
async def test_patch_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.PatchServiceAccountRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the ... | @pytest.mark.asyncio
async def test_patch_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.PatchServiceAccountRequest):
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the ... | _credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.patch_service_account),
'__call__') as call:
client.patch_service_account()
call.assert_c... | 120 | 120 | 403 | 32 | 88 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_patch_service_account_async | test_patch_service_account_async | 1,603 | 1,647 | 1,603 | 1,604 | 76b748074413b32d8de5bdc447028b3abe3c0333 | bigcode/the-stack | train |
689b79f240a7f1cae12ac5b6 | train | function | @pytest.mark.parametrize("transport_class", [
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
])
def test_transport_adc(transport_class):
# Test default credentials are used if not provided.
with mock.patch.object(google.auth, 'default') as adc:
adc.return_value = (ga_credential... | @pytest.mark.parametrize("transport_class", [
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
])
def test_transport_adc(transport_class):
# Test default credentials are used if not provided.
| with mock.patch.object(google.auth, 'default') as adc:
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport_class()
adc.assert_called_once()
| =ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
@pytest.mark.parametrize("transport_class", [
transports.IAMGrpcTransport,
transports.IAMGrpcAsyncIOTransport,
])
def test_transport_adc(transport_class):
# Test default credentials are used if not provided... | 64 | 64 | 83 | 44 | 19 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_transport_adc | test_transport_adc | 6,765 | 6,774 | 6,765 | 6,770 | 878affaec73e05984f1df728110d9db7123e86ad | bigcode/the-stack | train |
927d213a6991d3c2737e0ca7 | train | function | @pytest.mark.parametrize("transport_class", [transports.IAMGrpcTransport, transports.IAMGrpcAsyncIOTransport])
def test_iam_transport_channel_mtls_with_client_cert_source(
transport_class
):
with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred:
with mock.patch.object(t... | @pytest.mark.parametrize("transport_class", [transports.IAMGrpcTransport, transports.IAMGrpcAsyncIOTransport])
def test_iam_transport_channel_mtls_with_client_cert_source(
transport_class
):
| with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred:
with mock.patch.object(transport_class, "create_channel") as grpc_create_channel:
mock_ssl_cred = mock.Mock()
grpc_ssl_channel_cred.return_value = mock_ssl_cred
mock_grpc_channel = m... | assert transport.grpc_channel == channel
assert transport._host == "squid.clam.whelk:443"
assert transport._ssl_channel_credentials == None
# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
# removed from grpc/grpc_asyncio transport constructor.
@pytest.mark.parametrize... | 105 | 105 | 353 | 41 | 64 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_transport_channel_mtls_with_client_cert_source | test_iam_transport_channel_mtls_with_client_cert_source | 7,081 | 7,120 | 7,081 | 7,084 | 500635f254de1ab542cf98d8c9b1fe3dedd40f51 | bigcode/the-stack | train |
0693084229dc6bbf9b6a718d | train | function | @pytest.mark.asyncio
async def test_disable_service_account_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.Dis... | @pytest.mark.asyncio
async def test_disable_service_account_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.DisableServiceAccountRequest()
request.name = 'name/value'
# Mock the actual... | assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_disable_service_account_field_headers_async():
| 69 | 69 | 233 | 15 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_disable_service_account_field_headers_async | test_disable_service_account_field_headers_async | 2,348 | 2,377 | 2,348 | 2,349 | 8f334a0be4a8a875c91689cfc660e03af8b131d5 | bigcode/the-stack | train |
2fa8a7da8b1047ad2046288e | train | function | @pytest.mark.asyncio
async def test_get_iam_policy_flattened_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_iam_policy),
... | @pytest.mark.asyncio
async def test_get_iam_policy_flattened_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.get_iam_policy),
'__call__') as call:
# Designate an appropriate return ... | with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.get_iam_policy(
iam_policy_pb2.GetIamPolicyRequest(),
resource='resource_value',
)
@pytest.mark.asyncio
async def test_get_iam_policy_flattened_async():
| 64 | 64 | 208 | 17 | 47 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_flattened_async | test_get_iam_policy_flattened_async | 4,233 | 4,257 | 4,233 | 4,234 | 907fc58ec5b216bfcff30419fa9a2d8f2983f2b7 | bigcode/the-stack | train |
d964c2d700b0c55a084dfcf1 | train | function | def test_undelete_role(transport: str = 'grpc', request_type=iam.UndeleteRoleRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual... | def test_undelete_role(transport: str = 'grpc', request_type=iam.UndeleteRoleRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | RPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
de... | 104 | 104 | 348 | 24 | 80 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_undelete_role | test_undelete_role | 6,099 | 6,138 | 6,099 | 6,099 | 73c7594d9017a9de205fae36b1fa62f19a6224fd | bigcode/the-stack | train |
5af14bdeab34399aec00a685 | train | function | def test_test_iam_permissions(transport: str = 'grpc', request_type=iam_policy_pb2.TestIamPermissionsRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we ar... | def test_test_iam_permissions(transport: str = 'grpc', request_type=iam_policy_pb2.TestIamPermissionsRequest):
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocking out the actual API, so just send an empty request.
request = request_type()
# Mock the actua... | to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.set_iam_policy(
iam_policy_pb2.SetIamPolicyRequest(),
resource='resource_value',
)
def test_test_iam_permissions(transport: str = 'grpc', request_... | 78 | 78 | 260 | 26 | 52 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions | test_test_iam_permissions | 4,527 | 4,554 | 4,527 | 4,527 | 97103fadc75b7a543fa5532d4bec20904a28cfaa | bigcode/the-stack | train |
b783bfd3637d15ebf4f12aa4 | train | function | def test_update_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call... | def test_update_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.update_role),
'__call__') as call:
client.update_ro... | _blob'
assert response.deleted is True
def test_update_role_from_dict():
test_update_role(request_type=dict)
def test_update_role_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 134 | 40 | 24 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_role_empty_call | test_update_role_empty_call | 5,795 | 5,810 | 5,795 | 5,797 | e426d69f1000fb93797f47209273888fe50c9f9d | bigcode/the-stack | train |
eb5c521aa22535bd9d63be2c | train | function | def test_transport_instance():
# A client may be instantiated with a custom transport instance.
transport = transports.IAMGrpcTransport(
credentials=ga_credentials.AnonymousCredentials(),
)
client = IAMClient(transport=transport)
assert client.transport is transport
| def test_transport_instance():
# A client may be instantiated with a custom transport instance.
| transport = transports.IAMGrpcTransport(
credentials=ga_credentials.AnonymousCredentials(),
)
client = IAMClient(transport=transport)
assert client.transport is transport
| (
credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = IAMClient(
client_options={"scopes": ["1", "2"]},
transport=transport,
)
def test_transport_instance():
# A client may be instantiated with a custom transport insta... | 64 | 64 | 55 | 18 | 46 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_transport_instance | test_transport_instance | 6,743 | 6,749 | 6,743 | 6,744 | 1492abc2781637907e0495a190b8b8a831ae4cfc | bigcode/the-stack | train |
09bc3de764eabcc3ec50e1af | train | function | def test_delete_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock ... | def test_delete_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.delete_service_account_key),
'__call__') as call:
c... | is None
def test_delete_service_account_key_from_dict():
test_delete_service_account_key(request_type=dict)
def test_delete_service_account_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
| 64 | 64 | 142 | 42 | 22 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_key_empty_call | test_delete_service_account_key_empty_call | 3,347 | 3,362 | 3,347 | 3,349 | ab94eed5955fc66ca38ecc776748c6062f6f1792 | bigcode/the-stack | train |
444f42b2d35edf017047a51e | train | function | @pytest.mark.asyncio
async def test_list_service_accounts_field_headers_async():
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.ListS... | @pytest.mark.asyncio
async def test_list_service_accounts_field_headers_async():
| client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = iam.ListServiceAccountsRequest()
request.name = 'name/value'
# Mock the actual c... | ]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'name=name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_list_service_accounts_field_headers_async():
| 71 | 71 | 238 | 15 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_accounts_field_headers_async | test_list_service_accounts_field_headers_async | 516 | 545 | 516 | 517 | d0d99c9bbeab0d3b4b8667ba1f8a5d04299dd8e8 | bigcode/the-stack | train |
ccba015f72cb7ae5650839e9 | train | function | def test_common_billing_account_path():
billing_account = "scallop"
expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, )
actual = IAMClient.common_billing_account_path(billing_account)
assert expected == actual
| def test_common_billing_account_path():
| billing_account = "scallop"
expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, )
actual = IAMClient.common_billing_account_path(billing_account)
assert expected == actual
| project": "winkle",
"service_account": "nautilus",
}
path = IAMClient.service_account_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_service_account_path(path)
assert expected == actual
def test_common_billing_account_path():
| 64 | 64 | 56 | 8 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_common_billing_account_path | test_common_billing_account_path | 7,203 | 7,207 | 7,203 | 7,203 | 22d3de0c6c6f8d170934bb2f9e42cf3f8f94da10 | bigcode/the-stack | train |
fef369e6e8691d350f5c6fb8 | train | function | def test_create_service_account_key_from_dict():
test_create_service_account_key(request_type=dict)
| def test_create_service_account_key_from_dict():
| test_create_service_account_key(request_type=dict)
| b'private_key_data_blob'
assert response.public_key_data == b'public_key_data_blob'
assert response.key_origin == iam.ServiceAccountKeyOrigin.USER_PROVIDED
assert response.key_type == iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED
def test_create_service_account_key_from_dict():
| 64 | 64 | 19 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_key_from_dict | test_create_service_account_key_from_dict | 2,916 | 2,917 | 2,916 | 2,916 | 79843bf8012ad2cc3a0f2310ffdc3dfb0b4bcc64 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.