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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ef3c27badb7acc37d35f9b82 | train | function | def test_query_grantable_roles_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.query_grantable_roles),
'__call__') as ca... | def test_query_grantable_roles_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.query_grantable_roles),
'__call__') as call:
# Designate an appropriate retur... | , pagers.QueryGrantableRolesAsyncPager)
assert response.next_page_token == 'next_page_token_value'
@pytest.mark.asyncio
async def test_query_grantable_roles_async_from_dict():
await test_query_grantable_roles_async(request_type=dict)
def test_query_grantable_roles_flattened():
| 64 | 64 | 196 | 11 | 53 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_flattened | test_query_grantable_roles_flattened | 4,869 | 4,890 | 4,869 | 4,869 | 1c57de200c1d7a4fd1daea5a58960335b550df0b | bigcode/the-stack | train |
76cab6dccaf66852e269f969 | train | function | def test_update_service_account_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.ServiceAccount()
request.name = 'name... | def test_update_service_account_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.ServiceAccount()
request.name = 'name/value'
# Mock the actual call within the gR... | '
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():
await test_update_service_account_async(request_type=dict)
def test_update_se... | 66 | 66 | 220 | 8 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_service_account_field_headers | test_update_service_account_field_headers | 1,472 | 1,500 | 1,472 | 1,472 | 349300785b78266d93d02aa94a0a309cd7482996 | bigcode/the-stack | train |
45042d3012e397227474f46c | train | function | def test_delete_service_account_key_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.DeleteServiceAccountKeyRequest()
... | def test_delete_service_account_key_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.DeleteServiceAccountKeyRequest()
request.name = 'name/value'
# Mock the actual ca... | [0] == iam.DeleteServiceAccountKeyRequest()
# Establish that the response is the type that we expect.
assert response is None
@pytest.mark.asyncio
async def test_delete_service_account_key_async_from_dict():
await test_delete_service_account_key_async(request_type=dict)
def test_delete_service_account_ke... | 67 | 67 | 224 | 9 | 58 | 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_field_headers | test_delete_service_account_key_field_headers | 3,398 | 3,426 | 3,398 | 3,398 | 5cdb06359522cf857817b8226561cc41062988fc | bigcode/the-stack | train |
28acafc6ebafc84bc5fb0119 | train | function | @pytest.mark.asyncio
async def test_disable_service_account_async_from_dict():
await test_disable_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_disable_service_account_async_from_dict():
| await test_disable_service_account_async(request_type=dict)
| len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == iam.DisableServiceAccountRequest()
# Establish that the response is the type that we expect.
assert response is None
@pytest.mark.asyncio
async def test_disable_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_disable_service_account_async_from_dict | test_disable_service_account_async_from_dict | 2,312 | 2,314 | 2,312 | 2,313 | e282fbff6ed08028eebab99bfc331df75ec3c89f | bigcode/the-stack | train |
331cc71fe1f5451b72a26e0c | train | function | def test_test_iam_permissions_from_dict_foreign():
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__') ... | def test_test_iam_permissions_from_dict_foreign():
| 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 ... | [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']
def test_test_iam_permissions_from_dict_foreign():
| 64 | 64 | 129 | 11 | 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_from_dict_foreign | test_test_iam_permissions_from_dict_foreign | 4,677 | 4,692 | 4,677 | 4,677 | d964fd69f1cfe83a1d10898ddfe1f8a5c30b5eeb | bigcode/the-stack | train |
92f9b7c0151bd973f62098dc | train | function | @pytest.mark.asyncio
async def test_patch_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.Patch... | @pytest.mark.asyncio
async def test_patch_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.PatchServiceAccountRequest()
request.service_account.name = 'service_account.name... | args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'service_account.name=service_account.name/value',
) in kw['metadata']
@pytest.mark.asyncio
async def test_patch_service_account_field_headers_async():
| 73 | 73 | 246 | 15 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_patch_service_account_field_headers_async | test_patch_service_account_field_headers_async | 1,686 | 1,715 | 1,686 | 1,687 | 970ef33708ebf18f9e9978aeba852a3fbf79331d | bigcode/the-stack | train |
6ed2a221c9aea0900074cd03 | train | function | def test_sign_blob_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.sign_blob),
'__call__') as call:
# Designate ... | def test_sign_blob_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.sign_blob),
'__call__') as call:
# Designate an appropriate return value for ... | ]
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_sign_blob_flattened():
| 64 | 64 | 205 | 8 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_blob_flattened | test_sign_blob_flattened | 3,696 | 3,719 | 3,696 | 3,696 | 0219dbd05da8ce612415ce4eadcfc957550a43a2 | bigcode/the-stack | train |
923caad38b3009838e444a96 | train | function | def test_delete_service_account_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_delete_service_account_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),
'__call__') as call:
clien... | assert response is None
def test_delete_service_account_from_dict():
test_delete_service_account(request_type=dict)
def test_delete_service_account_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 | 138 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_delete_service_account_empty_call | test_delete_service_account_empty_call | 1,749 | 1,764 | 1,749 | 1,751 | a226aa606b45892b8b3baa18e8c15cd49245e6e5 | bigcode/the-stack | train |
9b63e1c0dff26c991d84f305 | train | function | @pytest.mark.asyncio
async def test_sign_jwt_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.sign_jwt),
'__ca... | @pytest.mark.asyncio
async def test_sign_jwt_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.sign_jwt),
'__call__') as call:
# Designate an appropriate return value ... | call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.sign_jwt(
iam.SignJwtRequest(),
name='name_value',
payload='payload_value',
)
@pytest.mark.asyncio
async def test_sign_jwt_flattened_async():
| 67 | 67 | 224 | 16 | 51 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_flattened_async | test_sign_jwt_flattened_async | 3,978 | 4,004 | 3,978 | 3,979 | 846e729e511f45565b338097712fdd784696f98b | bigcode/the-stack | train |
acef4c41a87eaf560ca95f2f | train | function | def test_service_account_path():
project = "cuttlefish"
service_account = "mussel"
expected = "projects/{project}/serviceAccounts/{service_account}".format(project=project, service_account=service_account, )
actual = IAMClient.service_account_path(project, service_account)
assert expected == actual
| def test_service_account_path():
| project = "cuttlefish"
service_account = "mussel"
expected = "projects/{project}/serviceAccounts/{service_account}".format(project=project, service_account=service_account, )
actual = IAMClient.service_account_path(project, service_account)
assert expected == actual
| opus",
"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_service_account_path():
| 64 | 64 | 68 | 6 | 57 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_service_account_path | test_service_account_path | 7,184 | 7,189 | 7,184 | 7,184 | 0351129cb1e7b821c4382a0c97fd39eb6af8e8da | bigcode/the-stack | train |
5c29ab1b43f671a9d272d840 | train | function | def test_sign_jwt_from_dict():
test_sign_jwt(request_type=dict)
| def test_sign_jwt_from_dict():
| test_sign_jwt(request_type=dict)
| 0] == iam.SignJwtRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.SignJwtResponse)
assert response.key_id == 'key_id_value'
assert response.signed_jwt == 'signed_jwt_value'
def test_sign_jwt_from_dict():
| 64 | 64 | 17 | 8 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_from_dict | test_sign_jwt_from_dict | 3,814 | 3,815 | 3,814 | 3,814 | 2b5d3b35d455cec39757ca21bc23f33aef524d4c | bigcode/the-stack | train |
3a969f5bf26757be1ccd146e | train | function | @pytest.mark.asyncio
async def test_undelete_role_async_from_dict():
await test_undelete_role_async(request_type=dict)
| @pytest.mark.asyncio
async def test_undelete_role_async_from_dict():
| await test_undelete_role_async(request_type=dict)
| == '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_undelete_role_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_undelete_role_async_from_dict | test_undelete_role_async_from_dict | 6,206 | 6,208 | 6,206 | 6,207 | 41ba72719fe4caac6f895f630720427c8211db00 | bigcode/the-stack | train |
53991bf7fe5725cdd457b82a | train | function | @pytest.mark.asyncio
async def test_get_service_account_async_from_dict():
await test_get_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_get_service_account_async_from_dict():
| await test_get_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_get_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_get_service_account_async_from_dict | test_get_service_account_async_from_dict | 929 | 931 | 929 | 930 | a262ffd19098489a172c8f107d8ebbef18d077aa | bigcode/the-stack | train |
d8ca82d5b5ddddbe3124bb55 | train | function | def test_upload_service_account_key_from_dict():
test_upload_service_account_key(request_type=dict)
| def test_upload_service_account_key_from_dict():
| test_upload_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_upload_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_upload_service_account_key_from_dict | test_upload_service_account_key_from_dict | 3,183 | 3,184 | 3,183 | 3,183 | a4a3f3a72c799c9689086f35a5d82f9b3211152d | bigcode/the-stack | train |
31fbb7f7d1d179fb8ad221bd | train | function | @pytest.mark.asyncio
async def test_delete_service_account_key_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.... | @pytest.mark.asyncio
async def test_delete_service_account_key_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.DeleteServiceAccountKeyRequest()
request.name = 'name/value'
# Mock the actu... | 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_key_field_headers_async():
| 71 | 71 | 237 | 16 | 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_key_field_headers_async | test_delete_service_account_key_field_headers_async | 3,429 | 3,458 | 3,429 | 3,430 | 2723eeeec2676d49fc31ea6f496b561e469b6f40 | bigcode/the-stack | train |
6eeebe89867768030ce776b9 | train | function | def test_sign_blob_from_dict():
test_sign_blob(request_type=dict)
| def test_sign_blob_from_dict():
| test_sign_blob(request_type=dict)
| assert args[0] == iam.SignBlobRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.SignBlobResponse)
assert response.key_id == 'key_id_value'
assert response.signature == b'signature_blob'
def test_sign_blob_from_dict():
| 64 | 64 | 15 | 7 | 57 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_blob_from_dict | test_sign_blob_from_dict | 3,573 | 3,574 | 3,573 | 3,573 | 70fdfe7223088f58ccab3a6c4c6610a0035fc48d | bigcode/the-stack | train |
b0648917290b9efbb6d5f662 | train | function | def test_update_service_account_from_dict():
test_update_service_account(request_type=dict)
| def test_update_service_account_from_dict():
| test_update_service_account(request_type=dict)
| email_value'
assert response.display_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
def test_update_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_update_service_account_from_dict | test_update_service_account_from_dict | 1,398 | 1,399 | 1,398 | 1,398 | 5c427b3a60a1524a9f2f007cd7d53800c9de4938 | bigcode/the-stack | train |
81fb436bd28280da510a286a | train | function | def test_enable_service_account_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.EnableServiceAccountRequest()
request... | def test_enable_service_account_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.EnableServiceAccountRequest()
request.name = 'name/value'
# Mock the actual call ... | 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():
await test_enable_service_account_async(request_type=dict)
def test_enable_service_ac... | 66 | 66 | 220 | 8 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_enable_service_account_field_headers | test_enable_service_account_field_headers | 2,172 | 2,200 | 2,172 | 2,172 | 92f7457f8fd5599e3e6b4d414f06a03314eb3952 | bigcode/the-stack | train |
ade7c2d570537b364fe51770 | train | function | def test_iam_client_client_options_from_dict():
with mock.patch('google.iam.admin_v1.services.iam.transports.IAMGrpcTransport.__init__') as grpc_transport:
grpc_transport.return_value = None
client = IAMClient(
client_options={'api_endpoint': 'squid.clam.whelk'}
)
grpc_tr... | def test_iam_client_client_options_from_dict():
| with mock.patch('google.iam.admin_v1.services.iam.transports.IAMGrpcTransport.__init__') as grpc_transport:
grpc_transport.return_value = None
client = IAMClient(
client_options={'api_endpoint': 'squid.clam.whelk'}
)
grpc_transport.assert_called_once_with(
cre... | credentials_file="credentials.json",
host=client.DEFAULT_ENDPOINT,
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_iam... | 64 | 64 | 138 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_client_options_from_dict | test_iam_client_client_options_from_dict | 379 | 394 | 379 | 379 | 48e5f6ae7e2f187568ebc7f0556ed033368fc043 | bigcode/the-stack | train |
248f87b4cab6ce28769ff801 | train | function | @pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [
(IAMClient, transports.IAMGrpcTransport, "grpc", "true"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio", "true"),
(IAMClient, transports.IAMGrpcTransport, "grpc", "false"),
(IAMAsyncClient... | @pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [
(IAMClient, transports.IAMGrpcTransport, "grpc", "true"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio", "true"),
(IAMClient, transports.IAMGrpcTransport, "grpc", "false"),
(IAMAsyncClient... | with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}):
options = client_options.ClientOptions(client_cert_source=client_cert_source_callback)
with mock.patch.object(transport_class, '__init__') as patched:
patched.return_value = None
cli... | @pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [
(IAMClient, transports.IAMGrpcTransport, "grpc", "true"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio", "true"),
(IAMClient, transports.IAMGrpcTransport, "grpc", "false"),
(IAMAsyncClient... | 249 | 248 | 828 | 249 | 0 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_mtls_env_auto | test_iam_client_mtls_env_auto | 249 | 329 | 249 | 263 | 3ac707ca9678e52ccda8b955cd967587a5504a91 | bigcode/the-stack | train |
0760df42e0926487376b5b21 | train | function | def test_client_ctx():
transports = [
'grpc',
]
for transport in transports:
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport
)
# Test client calls underlying transport.
with mock.patch.object(type(clie... | def test_client_ctx():
| transports = [
'grpc',
]
for transport in transports:
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport
)
# Test client calls underlying transport.
with mock.patch.object(type(client.transport), "close")... | ():
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport
)
with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close:
with client:
close.assert_not_called()
close.ass... | 64 | 64 | 84 | 5 | 59 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_client_ctx | test_client_ctx | 7,336 | 7,350 | 7,336 | 7,336 | 25481996119ee832b6798d56b999999db7b5aef0 | bigcode/the-stack | train |
cbc762b663d48d6892371dfb | train | function | def test_create_service_account_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_create_service_account_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.create_service_account),
'__call__') as call:
clien... | assert response.disabled is True
def test_create_service_account_from_dict():
test_create_service_account(request_type=dict)
def test_create_service_account_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 | 138 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_empty_call | test_create_service_account_empty_call | 1,127 | 1,142 | 1,127 | 1,129 | 53dfae847c0a5232f640f69fa52b1dddba71dace | bigcode/the-stack | train |
1d6b33f507ab214a3f16f7b0 | train | function | def test_patch_service_account_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 a... | def test_patch_service_account_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.patch_service_account),
'__call__') as call:
client... | assert response.disabled is True
def test_patch_service_account_from_dict():
test_patch_service_account(request_type=dict)
def test_patch_service_account_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 | 139 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_patch_service_account_empty_call | test_patch_service_account_empty_call | 1,585 | 1,600 | 1,585 | 1,587 | 8084305da3d86b873939a02c90c616039c586a34 | bigcode/the-stack | train |
d67f768193740e3dde5caacc | train | function | def test_common_organization_path():
organization = "whelk"
expected = "organizations/{organization}".format(organization=organization, )
actual = IAMClient.common_organization_path(organization)
assert expected == actual
| def test_common_organization_path():
| organization = "whelk"
expected = "organizations/{organization}".format(organization=organization, )
actual = IAMClient.common_organization_path(organization)
assert expected == actual
| test_parse_common_folder_path():
expected = {
"folder": "clam",
}
path = IAMClient.common_folder_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_folder_path(path)
assert expected == actual
def test_common_organization_path():
| 64 | 64 | 47 | 7 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_common_organization_path | test_common_organization_path | 7,237 | 7,241 | 7,237 | 7,237 | c74a0a0f80d114b03fc82754715a28b6b6bec09a | bigcode/the-stack | train |
5fd441ad68acd8144aa774e0 | train | function | def test_iam_client_get_transport_class():
transport = IAMClient.get_transport_class()
available_transports = [
transports.IAMGrpcTransport,
]
assert transport in available_transports
transport = IAMClient.get_transport_class("grpc")
assert transport == transports.IAMGrpcTransport
| def test_iam_client_get_transport_class():
| transport = IAMClient.get_transport_class()
available_transports = [
transports.IAMGrpcTransport,
]
assert transport in available_transports
transport = IAMClient.get_transport_class("grpc")
assert transport == transports.IAMGrpcTransport
|
assert isinstance(client, client_class)
client = client_class.from_service_account_json("dummy/file/path.json")
assert client.transport._credentials == creds
assert isinstance(client, client_class)
assert client.transport._host == 'iam.googleapis.com:443'
def test_iam_client_g... | 64 | 64 | 62 | 9 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_get_transport_class | test_iam_client_get_transport_class | 141 | 149 | 141 | 141 | 85835bf9ed406850a98bd700faf2a8da2371ac78 | bigcode/the-stack | train |
1e76f70895036effaef05fb6 | train | function | def test_sign_jwt(transport: str = 'grpc', request_type=iam.SignJwtRequest):
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 j... | def test_sign_jwt(transport: str = 'grpc', request_type=iam.SignJwtRequest):
| 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... | Attempting to call a method with both a request object and flattened
# fields is an error.
with pytest.raises(ValueError):
await client.sign_blob(
iam.SignBlobRequest(),
name='name_value',
bytes_to_sign=b'bytes_to_sign_blob',
)
def test_sign_jwt(transport: st... | 80 | 80 | 269 | 21 | 59 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt | test_sign_jwt | 3,782 | 3,811 | 3,782 | 3,782 | 824913a99dd3ba25fd2bec0e1b3d818703a49db7 | bigcode/the-stack | train |
86638525342312da12714522 | train | function | def test_update_service_account_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_update_service_account_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_service_account),
'__call__') as call:
clien... | assert response.disabled is True
def test_update_service_account_from_dict():
test_update_service_account(request_type=dict)
def test_update_service_account_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 | 136 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_service_account_empty_call | test_update_service_account_empty_call | 1,402 | 1,417 | 1,402 | 1,404 | 813e037397cca0f8fe604c5253b004a414b72c44 | bigcode/the-stack | train |
506531b1c51976cac50fc519 | train | function | def test_query_grantable_roles_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 a... | def test_query_grantable_roles_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_grantable_roles),
'__call__') as call:
client... | def test_query_grantable_roles_from_dict():
test_query_grantable_roles(request_type=dict)
def test_query_grantable_roles_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_grantable_roles_empty_call | test_query_grantable_roles_empty_call | 4,815 | 4,830 | 4,815 | 4,817 | 1faa22a0a5d706e1640827e1db6b1b11d1ce1bf1 | bigcode/the-stack | train |
6f45cb78545d745e39af82f9 | train | function | def test_query_grantable_roles_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.query_grantable_roles(
... | def test_query_grantable_roles_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.query_grantable_roles(
iam.QueryGrantableRolesRequest(),
... | call was made with the expected
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].full_resource_name == 'full_resource_name_value'
def test_query_grantable_roles_flattened_error():
| 64 | 64 | 87 | 12 | 52 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_flattened_error | test_query_grantable_roles_flattened_error | 4,893 | 4,904 | 4,893 | 4,893 | 2f1b3a2e3246ab3a57185f8c90db2f16bf9914d4 | bigcode/the-stack | train |
bd15d0d343e63b12d2965166 | train | function | def test_list_service_account_keys(transport: str = 'grpc', request_type=iam.ListServiceAccountKeysRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are ... | def test_list_service_account_keys(transport: str = 'grpc', request_type=iam.ListServiceAccountKeysRequest):
| 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... |
# 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_list_service_account_keys(transport: str = 'grpc', request_type=iam.ListServiceAccountKeysRequest):
| 71 | 71 | 237 | 24 | 47 | 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 | test_list_service_account_keys | 2,380 | 2,405 | 2,380 | 2,380 | ff96cb754a2d59518fed90981da14277ca429845 | bigcode/the-stack | train |
84309075a9a4820c8e10478b | train | function | def client_cert_source_callback():
return b"cert bytes", b"key bytes"
| def client_cert_source_callback():
| return b"cert bytes", b"key bytes"
| 0",
)
requires_google_auth_gte_1_25_0 = pytest.mark.skipif(
packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"),
reason="This test requires google-auth >= 1.25.0",
)
def client_cert_source_callback():
| 64 | 64 | 18 | 6 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | client_cert_source_callback | client_cert_source_callback | 64 | 65 | 64 | 64 | 434b7840ef4d9d3464b78b6876ca7bf4bc6840b1 | bigcode/the-stack | train |
210c16c16005654ce64c2465 | train | function | @pytest.mark.asyncio
async def test_undelete_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.UndeleteRoleR... | @pytest.mark.asyncio
async def test_undelete_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.UndeleteRoleRequest()
request.name = 'name/value'
# Mock the actual call wit... | 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_undelete_role_field_headers_async():
| 71 | 71 | 239 | 16 | 55 | 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_async | test_undelete_role_field_headers_async | 6,242 | 6,271 | 6,242 | 6,243 | f20e7e9d1098655e86e404b0ac195fbf3fb733c7 | bigcode/the-stack | train |
b01b8c46ccd63273d8e7cb0f | train | function | def test_lint_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... | def test_lint_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.lint_policy),
'__call__') as call:
client.lint_poli... | iam.LintPolicyResponse)
def test_lint_policy_from_dict():
test_lint_policy(request_type=dict)
def test_lint_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 | 138 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_lint_policy_empty_call | test_lint_policy_empty_call | 6,659 | 6,674 | 6,659 | 6,661 | f6288f62ee5086b3d58a1cd8d69816ba51540260 | bigcode/the-stack | train |
d54b066798b028edc0014fba | train | function | @pytest.mark.asyncio
async def test_list_roles_async(transport: str = 'grpc_asyncio', request_type=iam.ListRolesRequest):
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_list_roles_async(transport: str = 'grpc_asyncio', request_type=iam.ListRolesRequest):
| 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 ... | (
type(client.transport.list_roles),
'__call__') as call:
client.list_roles()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.ListRolesRequest()
@pytest.mark.asyncio
async def test_list_roles_async(transport: str = 'grpc_asyncio', reques... | 79 | 79 | 264 | 29 | 50 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_roles_async | test_list_roles_async | 5,182 | 5,210 | 5,182 | 5,183 | 555e8faba457215bbcfe6e896070b6b455c1a20f | bigcode/the-stack | train |
9be2267ff8bdb8a46b755f3a | train | function | def test_list_service_accounts_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 a... | def test_list_service_accounts_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.list_service_accounts),
'__call__') as call:
client... | 'next_page_token_value'
def test_list_service_accounts_from_dict():
test_list_service_accounts(request_type=dict)
def test_list_service_accounts_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 | 138 | 41 | 23 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_accounts_empty_call | test_list_service_accounts_empty_call | 431 | 446 | 431 | 433 | 9c0ffce744d24d93fd9a7c24b4735817ebb4b331 | bigcode/the-stack | train |
90323c535b3201fdd54747b8 | train | function | def test_list_service_account_keys_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.list_service_account_key... | def test_list_service_account_keys_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.list_service_account_keys(
iam.ListServiceAccountKeysRequest(),
... | .mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
assert args[0].key_types == [iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED]
def test_list_service_account_keys_flattened_error():
| 64 | 64 | 97 | 11 | 53 | 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_flattened_error | test_list_service_account_keys_flattened_error | 2,553 | 2,565 | 2,553 | 2,553 | c21f2bbc015739fee73badaa6afd66b625fa02d4 | bigcode/the-stack | train |
41044102e5a2c7b12435ce7e | train | function | @pytest.mark.asyncio
async def test_create_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.CreateServiceAccountRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as th... | @pytest.mark.asyncio
async def test_create_service_account_async(transport: str = 'grpc_asyncio', request_type=iam.CreateServiceAccountRequest):
| 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 ... | =ga_credentials.AnonymousCredentials(),
transport='grpc',
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client.transport.create_service_account),
'__call__') as call:
client.create_service_account()
call.ass... | 120 | 120 | 401 | 31 | 89 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_async | test_create_service_account_async | 1,145 | 1,189 | 1,145 | 1,146 | 8deb0375b8076d2d8467a12942c66159df4a5620 | bigcode/the-stack | train |
874d3617b1cd09e0f34fdb25 | train | function | def test_list_service_accounts_from_dict():
test_list_service_accounts(request_type=dict)
| def test_list_service_accounts_from_dict():
| test_list_service_accounts(request_type=dict)
| .mock_calls[0]
assert args[0] == iam.ListServiceAccountsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListServiceAccountsPager)
assert response.next_page_token == 'next_page_token_value'
def test_list_service_accounts_from_dict():
| 64 | 64 | 17 | 8 | 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_from_dict | test_list_service_accounts_from_dict | 427 | 428 | 427 | 427 | 9b2d0f2900a5179d17e4c2b82f35128e7b48c83c | bigcode/the-stack | train |
1b1141a0869eeea76e442cf7 | train | function | def test_parse_service_account_path():
expected = {
"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 == ac... | def test_parse_service_account_path():
| expected = {
"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
| uttlefish"
service_account = "mussel"
expected = "projects/{project}/serviceAccounts/{service_account}".format(project=project, service_account=service_account, )
actual = IAMClient.service_account_path(project, service_account)
assert expected == actual
def test_parse_service_account_path():
| 64 | 64 | 69 | 7 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_parse_service_account_path | test_parse_service_account_path | 7,192 | 7,201 | 7,192 | 7,192 | 3ae625e2fb66f554c37adabe6c15e30eeb40c39e | bigcode/the-stack | train |
cfacf5415460c3f71bf5c385 | train | function | @pytest.mark.asyncio
async def test_create_role_async_from_dict():
await test_create_role_async(request_type=dict)
| @pytest.mark.asyncio
async def test_create_role_async_from_dict():
| await test_create_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_create_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_create_role_async_from_dict | test_create_role_async_from_dict | 5,681 | 5,683 | 5,681 | 5,682 | eb3cf021873394bff0fff61725283e9c74fb23d1 | bigcode/the-stack | train |
c0c8df8546d3dec78c73f464 | train | function | def test_create_service_account_key_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.CreateServiceAccountKeyRequest()
... | def test_create_service_account_key_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.CreateServiceAccountKeyRequest()
request.name = 'name/value'
# Mock the actual ca... | .key_origin == iam.ServiceAccountKeyOrigin.USER_PROVIDED
assert response.key_type == iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED
@pytest.mark.asyncio
async def test_create_service_account_key_async_from_dict():
await test_create_service_account_key_async(request_type=dict)
def test_create_service_a... | 68 | 68 | 227 | 9 | 59 | 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_field_headers | test_create_service_account_key_field_headers | 2,986 | 3,014 | 2,986 | 2,986 | f1a5fcf131c9f2248c8289feac66c7589f5d4e7a | bigcode/the-stack | train |
96e04b88102676cf95d0b518 | train | function | def test_patch_service_account_from_dict():
test_patch_service_account(request_type=dict)
| def test_patch_service_account_from_dict():
| test_patch_service_account(request_type=dict)
| email_value'
assert response.display_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
def test_patch_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_patch_service_account_from_dict | test_patch_service_account_from_dict | 1,581 | 1,582 | 1,581 | 1,581 | b11a89c496088b966ac8aa445136386b48d89a1c | bigcode/the-stack | train |
1ad52e8d7c65b580fdef5013 | train | function | @pytest.mark.asyncio
async def test_update_role_async(transport: str = 'grpc_asyncio', request_type=iam.UpdateRoleRequest):
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_update_role_async(transport: str = 'grpc_asyncio', request_type=iam.UpdateRoleRequest):
| 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.update_role),
'__call__') as call:
client.update_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_update_role_async | test_update_role_async | 5,813 | 5,853 | 5,813 | 5,814 | 8eae5d4e78ae5fe5b2e13940463038fa21234dca | bigcode/the-stack | train |
49e3e025d8d72bc9dc9cc609 | train | function | @pytest.mark.asyncio
async def test_delete_service_account_async_from_dict():
await test_delete_service_account_async(request_type=dict)
| @pytest.mark.asyncio
async def test_delete_service_account_async_from_dict():
| await test_delete_service_account_async(request_type=dict)
| len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0] == iam.DeleteServiceAccountRequest()
# Establish that the response is the type that we expect.
assert response is None
@pytest.mark.asyncio
async def test_delete_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_delete_service_account_async_from_dict | test_delete_service_account_async_from_dict | 1,795 | 1,797 | 1,795 | 1,796 | 29b50fe5836682f390979a9b134ca5fb87ed2e85 | bigcode/the-stack | train |
82286e8dcbe3dcb94ea0f176 | train | function | @pytest.mark.asyncio
async def test_query_grantable_roles_async_from_dict():
await test_query_grantable_roles_async(request_type=dict)
| @pytest.mark.asyncio
async def test_query_grantable_roles_async_from_dict():
| await test_query_grantable_roles_async(request_type=dict)
| iam.QueryGrantableRolesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.QueryGrantableRolesAsyncPager)
assert response.next_page_token == 'next_page_token_value'
@pytest.mark.asyncio
async def test_query_grantable_roles_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_grantable_roles_async_from_dict | test_query_grantable_roles_async_from_dict | 4,864 | 4,866 | 4,864 | 4,865 | 3f31d52f2300da035980a6639a47c7549ea574a9 | bigcode/the-stack | train |
35bb4ed4cc1a24c8afe2d422 | train | function | def test_update_role_from_dict():
test_update_role(request_type=dict)
| def test_update_role_from_dict():
| test_update_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_update_role_from_dict():
| 64 | 64 | 15 | 7 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_role_from_dict | test_update_role_from_dict | 5,791 | 5,792 | 5,791 | 5,791 | 79465ecc15d220f3627035ccfd25571b8c02a263 | bigcode/the-stack | train |
89d7f60e7225f7c1b1ea178c | train | function | def test_sign_jwt_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_jwt(
iam.SignJwtRequest(... | def test_sign_jwt_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_jwt(
iam.SignJwtRequest(),
name='name_value',
... |
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
assert args[0].payload == 'payload_value'
def test_sign_jwt_flattened_error():
| 64 | 64 | 83 | 10 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_flattened_error | test_sign_jwt_flattened_error | 3,963 | 3,975 | 3,963 | 3,963 | d47c5aee622426b95096d35ab05d064a54ce9211 | bigcode/the-stack | train |
0ce7d64f6054b4a47a933860 | train | function | def test_list_service_account_keys_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 t... | def test_list_service_account_keys_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.list_service_account_keys),
'__call__') as call:
cl... | KeysResponse)
def test_list_service_account_keys_from_dict():
test_list_service_account_keys(request_type=dict)
def test_list_service_account_keys_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_list_service_account_keys_empty_call | test_list_service_account_keys_empty_call | 2,412 | 2,427 | 2,412 | 2,414 | 14d71b075cd6822e14ed9ae6d3ab169fb2bc0d36 | bigcode/the-stack | train |
31a4d060f0dfcba2870b367a | train | function | def test_parse_common_organization_path():
expected = {
"organization": "octopus",
}
path = IAMClient.common_organization_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_organization_path(path)
assert expected == actual
| def test_parse_common_organization_path():
| expected = {
"organization": "octopus",
}
path = IAMClient.common_organization_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_organization_path(path)
assert expected == actual
| _path(path)
assert expected == actual
def test_common_organization_path():
organization = "whelk"
expected = "organizations/{organization}".format(organization=organization, )
actual = IAMClient.common_organization_path(organization)
assert expected == actual
def test_parse_common_organization_path... | 64 | 64 | 62 | 8 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_parse_common_organization_path | test_parse_common_organization_path | 7,244 | 7,252 | 7,244 | 7,244 | 6efacc7540db9654c61684c1376592c03a14f84f | bigcode/the-stack | train |
b9da0c9f2d94d694ce12cbe4 | train | function | @pytest.mark.asyncio
async def test_update_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.Serv... | @pytest.mark.asyncio
async def test_update_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.ServiceAccount()
request.name = 'name/value'
# Mock the actual call within t... | 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_service_account_field_headers_async():
| 70 | 70 | 234 | 15 | 55 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_update_service_account_field_headers_async | test_update_service_account_field_headers_async | 1,503 | 1,532 | 1,503 | 1,504 | cdf9b8407b3df2060db2879a78285b6d44ad87f7 | bigcode/the-stack | train |
5c6ca41c7640a6249491ffa4 | train | function | @pytest.mark.asyncio
async def test_get_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.GetServ... | @pytest.mark.asyncio
async def test_get_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.GetServiceAccountRequest()
request.name = 'name/value'
# Mock the actual cal... | 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_get_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_get_service_account_field_headers_async | test_get_service_account_field_headers_async | 965 | 994 | 965 | 966 | b6b26c67791e833663414b4669341c964c85a360 | bigcode/the-stack | train |
d1fc37d05bd174dd03a8ee34 | train | function | def test_sign_blob_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.SignBlobRequest()
request.name = 'name/value'
... | def test_sign_blob_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.SignBlobRequest()
request.name = 'name/value'
# Mock the actual call within the g... | expect.
assert isinstance(response, iam.SignBlobResponse)
assert response.key_id == 'key_id_value'
assert response.signature == b'signature_blob'
@pytest.mark.asyncio
async def test_sign_blob_async_from_dict():
await test_sign_blob_async(request_type=dict)
def test_sign_blob_field_headers():
| 65 | 65 | 219 | 7 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_blob_field_headers | test_sign_blob_field_headers | 3,633 | 3,661 | 3,633 | 3,633 | 06fc66b2058b296876896e1d2cf7688953106172 | bigcode/the-stack | train |
81059d079c36376147f79631 | train | function | @pytest.mark.asyncio
async def test_query_testable_permissions_async_pages():
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_pages():
| 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:
... | client.query_testable_permissions(request={},)
assert async_pager.next_page_token == 'abc'
responses = []
async for response in async_pager:
responses.append(response)
assert len(responses) == 6
assert all(isinstance(i, iam.Permission)
for i in re... | 79 | 79 | 265 | 15 | 64 | 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_pages | test_query_testable_permissions_async_pages | 6,499 | 6,541 | 6,499 | 6,500 | 95cbb2717f9ace9a644fcfd846bf6bbc81fe1a78 | bigcode/the-stack | train |
6c139cb931d7f666d97b38cb | train | function | def test_test_iam_permissions_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_policy_pb2.TestIamPermissionsRequest()
... | def test_test_iam_permissions_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_policy_pb2.TestIamPermissionsRequest()
request.resource = 'resource/value'
# Mock... | 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():
await test_test_iam_permissions_async(request_type=dict)
de... | 70 | 70 | 234 | 9 | 61 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_test_iam_permissions_field_headers | test_test_iam_permissions_field_headers | 4,615 | 4,643 | 4,615 | 4,615 | 53f7fbbea27977a128f63d5fb3eaba96da85e7a6 | bigcode/the-stack | train |
abd2485bb8cddc30e52c05b4 | train | function | @pytest.mark.asyncio
async def test_list_roles_async_from_dict():
await test_list_roles_async(request_type=dict)
| @pytest.mark.asyncio
async def test_list_roles_async_from_dict():
| await test_list_roles_async(request_type=dict)
| assert args[0] == iam.ListRolesRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListRolesAsyncPager)
assert response.next_page_token == 'next_page_token_value'
@pytest.mark.asyncio
async def test_list_roles_async_from_dict():
| 64 | 64 | 24 | 14 | 50 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_roles_async_from_dict | test_list_roles_async_from_dict | 5,213 | 5,215 | 5,213 | 5,214 | f90d0f7c45d945a162ae19aa6a3e2afedde2e5bc | bigcode/the-stack | train |
8338ec059528902d33c43c9e | train | function | @pytest.mark.asyncio
async def test_query_grantable_roles_async_pages():
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_grantable_roles... | @pytest.mark.asyncio
async def test_query_grantable_roles_async_pages():
| 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_grantable_roles),
'__call__', new_callable=mock.AsyncMock) as call:
... | .query_grantable_roles(request={},)
assert async_pager.next_page_token == 'abc'
responses = []
async for response in async_pager:
responses.append(response)
assert len(responses) == 6
assert all(isinstance(i, iam.Role)
for i in responses)
@pytest.m... | 80 | 80 | 268 | 16 | 64 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_async_pages | test_query_grantable_roles_async_pages | 5,086 | 5,128 | 5,086 | 5,087 | 00e2118b82c7bb2546dc45c6ae77c59391ac63fe | bigcode/the-stack | train |
d332c6bfcc3d7fab389d1e6f | train | function | def test_patch_service_account_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.PatchServiceAccountRequest()
request.s... | def test_patch_service_account_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.PatchServiceAccountRequest()
request.service_account.name = 'service_account.name/valu... | '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_patch_service_account_async_from_dict():
await test_patch_service_account_async(request_type=dict)
def test_p... | 69 | 69 | 232 | 8 | 61 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_patch_service_account_field_headers | test_patch_service_account_field_headers | 1,655 | 1,683 | 1,655 | 1,655 | 0ec9b38705ab7629821ad8c1c2d8fe0e39db6bc8 | bigcode/the-stack | train |
3f8d7ad99516f3830178290c | train | function | @pytest.mark.asyncio
async def test_sign_jwt_async_from_dict():
await test_sign_jwt_async(request_type=dict)
| @pytest.mark.asyncio
async def test_sign_jwt_async_from_dict():
| await test_sign_jwt_async(request_type=dict)
| ()
# Establish that the response is the type that we expect.
assert isinstance(response, iam.SignJwtResponse)
assert response.key_id == 'key_id_value'
assert response.signed_jwt == 'signed_jwt_value'
@pytest.mark.asyncio
async def test_sign_jwt_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_sign_jwt_async_from_dict | test_sign_jwt_async_from_dict | 3,869 | 3,871 | 3,869 | 3,870 | 02d316299962473700dbdaddaf7d289e3b7298e8 | bigcode/the-stack | train |
376c055ac9a77841bd928afa | train | function | @pytest.mark.asyncio
async def test_create_service_account_key_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_create_service_account_key_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.create_service_account_key(
iam.CreateServiceAccountKey... | _value'
assert args[0].private_key_type == iam.ServiceAccountPrivateKeyType.TYPE_PKCS12_FILE
assert args[0].key_algorithm == iam.ServiceAccountKeyAlgorithm.KEY_ALG_RSA_1024
@pytest.mark.asyncio
async def test_create_service_account_key_flattened_error_async():
| 64 | 64 | 124 | 18 | 45 | 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_async | test_create_service_account_key_flattened_error_async | 3,124 | 3,138 | 3,124 | 3,125 | c1003ae2cc66fa319148c05657dba62aa5fdeb94 | bigcode/the-stack | train |
dda6747bb1d29debf3571781 | train | function | @pytest.mark.parametrize("client_class,transport_class,transport_name", [
(IAMClient, transports.IAMGrpcTransport, "grpc"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_client_options_credentials_file(client_class, transport_class, transport_name):
# Check the... | @pytest.mark.parametrize("client_class,transport_class,transport_name", [
(IAMClient, transports.IAMGrpcTransport, "grpc"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_client_options_credentials_file(client_class, transport_class, transport_name):
# Check the... | options = client_options.ClientOptions(
credentials_file="credentials.json"
)
with mock.patch.object(transport_class, '__init__') as patched:
patched.return_value = None
client = client_class(client_options=options)
patched.assert_called_once_with(
credentials=Non... | @pytest.mark.parametrize("client_class,transport_class,transport_name", [
(IAMClient, transports.IAMGrpcTransport, "grpc"),
(IAMAsyncClient, transports.IAMGrpcAsyncIOTransport, "grpc_asyncio"),
])
def test_iam_client_client_options_credentials_file(client_class, transport_class, transport_name):
# Check the... | 76 | 64 | 191 | 76 | 0 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_client_client_options_credentials_file | test_iam_client_client_options_credentials_file | 355 | 376 | 355 | 360 | d8cd2a4adc335caae6d20f390aad842292d0fc01 | bigcode/the-stack | train |
487398893ca4b59ec1f0a2d7 | train | function | def test_list_service_accounts_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.list_service_accounts(
... | def test_list_service_accounts_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.list_service_accounts(
iam.ListServiceAccountsRequest(),
... | # 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_list_service_accounts_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_list_service_accounts_flattened_error | test_list_service_accounts_flattened_error | 572 | 583 | 572 | 572 | 61812ed99f8b03db650297548adefa454153ed23 | bigcode/the-stack | train |
b973e3c63ff1ce2598b6c03c | train | function | @pytest.mark.asyncio
async def test_list_service_account_keys_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.list_servic... | @pytest.mark.asyncio
async def test_list_service_account_keys_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.list_service_account_keys),
'__call__') as call:
# Designate an appropri... | request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.list_service_account_keys(
iam.ListServiceAccountKeysRequest(),
name='name_value',
key_types=[iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED],
)
@pytest.mark.asy... | 75 | 75 | 251 | 17 | 58 | 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_flattened_async | test_list_service_account_keys_flattened_async | 2,568 | 2,594 | 2,568 | 2,569 | 55a0a3f08cbee19b339ddb0cc39dc622e638a5de | bigcode/the-stack | train |
a937d72e0af43540f0fed290 | train | function | @pytest.mark.asyncio
async def test_delete_role_async(transport: str = 'grpc_asyncio', request_type=iam.DeleteRoleRequest):
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_delete_role_async(transport: str = 'grpc_asyncio', request_type=iam.DeleteRoleRequest):
| 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.delete_role),
'__call__') as call:
client.delete_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_delete_role_async | test_delete_role_async | 5,988 | 6,028 | 5,988 | 5,989 | a6e275d95f3163f38a075bbb5a66abb1dd00325d | bigcode/the-stack | train |
1a676e034269141aba65ad56 | train | function | def test_query_testable_permissions(transport: str = 'grpc', request_type=iam.QueryTestablePermissionsRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we a... | def test_query_testable_permissions(transport: str = 'grpc', request_type=iam.QueryTestablePermissionsRequest):
| 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... | 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_query_testable_permissions(transport: str = 'grpc', request_type=iam.QueryTestablePermissionsRequest):
| 78 | 78 | 261 | 24 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_testable_permissions | test_query_testable_permissions | 6,274 | 6,301 | 6,274 | 6,274 | 498b59263cd43070d85c963df4b52659b72de13b | bigcode/the-stack | train |
8a30f7453fafe2968ad3c189 | train | function | @pytest.mark.asyncio
async def test_list_service_account_keys_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_list_service_account_keys_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.list_service_account_keys(
iam.ListServiceAccountKeysRe... | _, args, _ = call.mock_calls[0]
assert args[0].name == 'name_value'
assert args[0].key_types == [iam.ListServiceAccountKeysRequest.KeyType.USER_MANAGED]
@pytest.mark.asyncio
async def test_list_service_account_keys_flattened_error_async():
| 64 | 64 | 106 | 18 | 46 | 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_flattened_error_async | test_list_service_account_keys_flattened_error_async | 2,597 | 2,610 | 2,597 | 2,598 | 4e406c04ed82b20e5e0b4773ec7ecfa7f621ab9f | bigcode/the-stack | train |
ba7a28c63aab56f42ccc9c51 | train | function | @pytest.mark.asyncio
async def test_create_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.create_ser... | @pytest.mark.asyncio
async def test_create_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.create_service_account_key),
'__call__') as call:
# Designate an appropr... | fields is an error.
with pytest.raises(ValueError):
client.create_service_account_key(
iam.CreateServiceAccountKeyRequest(),
name='name_value',
private_key_type=iam.ServiceAccountPrivateKeyType.TYPE_PKCS12_FILE,
key_algorithm=iam.ServiceAccountKeyAlgorithm.KE... | 86 | 86 | 287 | 17 | 69 | 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_async | test_create_service_account_key_flattened_async | 3,093 | 3,121 | 3,093 | 3,094 | 9ac42e8785687b28820f8dba1a6ec05e23b2f7f5 | bigcode/the-stack | train |
ea5a65d68547643b10a19ccd | train | function | def test_disable_service_account_from_dict():
test_disable_service_account(request_type=dict)
| def test_disable_service_account_from_dict():
| test_disable_service_account(request_type=dict)
| .
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0] == iam.DisableServiceAccountRequest()
# Establish that the response is the type that we expect.
assert response is None
def test_disable_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_disable_service_account_from_dict | test_disable_service_account_from_dict | 2,262 | 2,263 | 2,262 | 2,262 | 1e2ff3701fc98331fdefedd51daf6e31204d250a | bigcode/the-stack | train |
c09cfa65481a8ea068e23905 | train | function | def test_iam_base_transport():
# Instantiate the base transport.
with mock.patch('google.iam.admin_v1.services.iam.transports.IAMTransport.__init__') as Transport:
Transport.return_value = None
transport = transports.IAMTransport(
credentials=ga_credentials.AnonymousCredentials(),
... | def test_iam_base_transport():
# Instantiate the base transport.
| with mock.patch('google.iam.admin_v1.services.iam.transports.IAMTransport.__init__') as Transport:
Transport.return_value = None
transport = transports.IAMTransport(
credentials=ga_credentials.AnonymousCredentials(),
)
# Every method on the transport should just blindly
... | assert isinstance(
client.transport,
transports.IAMGrpcTransport,
)
def test_iam_base_transport_error():
# Passing both a credentials object and credentials_file should raise an error
with pytest.raises(core_exceptions.DuplicateCredentialArgs):
transport = transports.IAMTranspor... | 92 | 92 | 308 | 14 | 78 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_base_transport | test_iam_base_transport | 6,795 | 6,841 | 6,795 | 6,796 | 2f8e06aa0e879f218ed3280fc97f77b4b069cd18 | bigcode/the-stack | train |
32c85e07c5990056871158f3 | train | function | @pytest.mark.asyncio
async def test_query_grantable_roles_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_grantable_roles... | @pytest.mark.asyncio
async def test_query_grantable_roles_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_grantable_roles),
'__call__', new_callable=mock.AsyncMock) as call:
... | roles=[
iam.Role(),
iam.Role(),
],
),
RuntimeError,
)
pages = list(client.query_grantable_roles(request={}).pages)
for page_, token in zip(pages, ['abc','def','ghi', '']):
assert page_.raw... | 84 | 84 | 281 | 17 | 66 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_grantable_roles_async_pager | test_query_grantable_roles_async_pager | 5,038 | 5,084 | 5,038 | 5,039 | 7da0e520fb727a197497dfde4372818dcbd8280b | bigcode/the-stack | train |
ca2e208038593a4686dddd3e | train | function | def test_create_role_from_dict():
test_create_role(request_type=dict)
| def test_create_role_from_dict():
| test_create_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_create_role_from_dict():
| 64 | 64 | 15 | 7 | 56 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_role_from_dict | test_create_role_from_dict | 5,616 | 5,617 | 5,616 | 5,616 | fb3522cafe2a79b0eb75eb9fd7f97bb8e566a8ba | bigcode/the-stack | train |
5de962cbb837c0d6512d0944 | train | function | @pytest.mark.parametrize("transport_class", [transports.IAMGrpcTransport, transports.IAMGrpcAsyncIOTransport])
def test_iam_transport_channel_mtls_with_adc(
transport_class
):
mock_ssl_cred = mock.Mock()
with mock.patch.multiple(
"google.auth.transport.grpc.SslCredentials",
__init__=mock.Moc... | @pytest.mark.parametrize("transport_class", [transports.IAMGrpcTransport, transports.IAMGrpcAsyncIOTransport])
def test_iam_transport_channel_mtls_with_adc(
transport_class
):
| mock_ssl_cred = mock.Mock()
with mock.patch.multiple(
"google.auth.transport.grpc.SslCredentials",
__init__=mock.Mock(return_value=None),
ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred),
):
with mock.patch.object(transport_class, "create_channel") as grpc_create... | mock_grpc_channel
assert transport._ssl_channel_credentials == mock_ssl_cred
# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
# removed from grpc/grpc_asyncio transport constructor.
@pytest.mark.parametrize("transport_class", [transports.IAMGrpcTransport, transport... | 87 | 87 | 293 | 39 | 48 | 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_adc | test_iam_transport_channel_mtls_with_adc | 7,125 | 7,160 | 7,125 | 7,128 | 0fd3d8dea4ba7c89ab30b51c9c71e91c357bbda1 | bigcode/the-stack | train |
65934ef455a6d7ddc3af3c97 | train | function | def test_create_service_account(transport: str = 'grpc', request_type=iam.CreateServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocki... | def test_create_service_account(transport: str = 'grpc', request_type=iam.CreateServiceAccountRequest):
| 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... | name == 'name_value'
@pytest.mark.asyncio
async def test_get_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.rais... | 115 | 115 | 385 | 22 | 93 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account | test_create_service_account | 1,077 | 1,120 | 1,077 | 1,077 | 98b8216ae60e3ba29f571a0df4191c19add33bd9 | bigcode/the-stack | train |
65007e881e7c78a45bf7c59b | train | function | @pytest.mark.asyncio
async def test_list_service_accounts_async_pages():
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.list_service_accounts... | @pytest.mark.asyncio
async def test_list_service_accounts_async_pages():
| 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.list_service_accounts),
'__call__', new_callable=mock.AsyncMock) as call:
... | await client.list_service_accounts(request={},)
assert async_pager.next_page_token == 'abc'
responses = []
async for response in async_pager:
responses.append(response)
assert len(responses) == 6
assert all(isinstance(i, iam.ServiceAccount)
for i ... | 79 | 79 | 264 | 14 | 65 | 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_pages | test_list_service_accounts_async_pages | 770 | 812 | 770 | 771 | 33d12c67ecdb5767ed7abea909c35a59ffebf8e0 | bigcode/the-stack | train |
6171a9de6de515c4cd58f9e9 | train | function | @pytest.mark.asyncio
async def test_enable_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.Enab... | @pytest.mark.asyncio
async def test_enable_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.EnableServiceAccountRequest()
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_enable_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_enable_service_account_field_headers_async | test_enable_service_account_field_headers_async | 2,203 | 2,232 | 2,203 | 2,204 | 621735a1b6fe6fb8cd587843f4a08af7c94be1ec | bigcode/the-stack | train |
e7873332455a18e83e783e16 | train | function | def test_sign_jwt_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.SignJwtRequest()
request.name = 'name/value'
#... | def test_sign_jwt_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.SignJwtRequest()
request.name = 'name/value'
# Mock the actual call within the gR... | (response, iam.SignJwtResponse)
assert response.key_id == 'key_id_value'
assert response.signed_jwt == 'signed_jwt_value'
@pytest.mark.asyncio
async def test_sign_jwt_async_from_dict():
await test_sign_jwt_async(request_type=dict)
def test_sign_jwt_field_headers():
| 66 | 66 | 222 | 8 | 58 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_sign_jwt_field_headers | test_sign_jwt_field_headers | 3,874 | 3,902 | 3,874 | 3,874 | 2ec4b3934daf400bf72b0d89103135104281ba5b | bigcode/the-stack | train |
452ab1f9fde65412bfab471c | train | function | def test_parse_common_location_path():
expected = {
"project": "winkle",
"location": "nautilus",
}
path = IAMClient.common_location_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_location_path(path)
assert expected == actual
| def test_parse_common_location_path():
| expected = {
"project": "winkle",
"location": "nautilus",
}
path = IAMClient.common_location_path(**expected)
# Check that the path construction is reversible.
actual = IAMClient.parse_common_location_path(path)
assert expected == actual
| ():
project = "cuttlefish"
location = "mussel"
expected = "projects/{project}/locations/{location}".format(project=project, location=location, )
actual = IAMClient.common_location_path(project, location)
assert expected == actual
def test_parse_common_location_path():
| 64 | 64 | 68 | 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_location_path | test_parse_common_location_path | 7,279 | 7,288 | 7,279 | 7,279 | fd980da450dd1dfe4b7bc5a3619b7b803536017a | bigcode/the-stack | train |
2219624c91500382fae364d8 | train | function | @pytest.mark.asyncio
async def test_list_roles_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.list_roles),
'__call... | @pytest.mark.asyncio
async def test_list_roles_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.list_roles),
'__call__', new_callable=mock.AsyncMock) as call:
# Set the r... | (
roles=[
iam.Role(),
iam.Role(),
],
),
RuntimeError,
)
pages = list(client.list_roles(request={}).pages)
for page_, token in zip(pages, ['abc','def','ghi', '']):
assert page_.raw_page.nex... | 79 | 79 | 264 | 14 | 64 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_roles_async_pager | test_list_roles_async_pager | 5,307 | 5,353 | 5,307 | 5,308 | 27238512e31fadbc3d5d43a10960e90d64001033 | bigcode/the-stack | train |
d869eb5e6a52493cf92275fa | train | function | def test_list_service_accounts_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.list_service_accounts),
'__call__') as call:
... | def test_list_service_accounts_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.list_service_accounts),
'__call__') as call:
# Set the response to a series of ... | ('name', ''),
)),
)
pager = client.list_service_accounts(request={})
assert pager._metadata == metadata
results = [i for i in pager]
assert len(results) == 6
assert all(isinstance(i, iam.ServiceAccount)
for i in results)
de... | 70 | 70 | 236 | 7 | 63 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_service_accounts_pages | test_list_service_accounts_pages | 681 | 720 | 681 | 681 | 21f778894ab308e6502653fb400c7767bd2676f4 | bigcode/the-stack | train |
45a0454418798706147cd12d | train | function | @pytest.mark.asyncio
async def test_list_service_account_keys_async(transport: str = 'grpc_asyncio', request_type=iam.ListServiceAccountKeysRequest):
client = IAMAsyncClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far ... | @pytest.mark.asyncio
async def test_list_service_account_keys_async(transport: str = 'grpc_asyncio', request_type=iam.ListServiceAccountKeysRequest):
| 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.list_service_account_keys()
call.assert_called()
_, args, _ = call.mock_calls[0]
assert args[0] == iam.ListServiceAccountKeysRequest()
@pytest.mark.asyncio
async def test_list_service_account_keys_async(transport: str = 'grpc_asyncio', request_type=iam.ListServiceAccou... | 75 | 75 | 253 | 33 | 42 | 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_async | test_list_service_account_keys_async | 2,430 | 2,456 | 2,430 | 2,431 | 272693e8c49643e10549cdb6d5fccefdf13fb131 | bigcode/the-stack | train |
71b69cc9bac47450e23112ad | train | function | def test_set_iam_policy_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_policy_pb2.SetIamPolicyRequest()
request.reso... | def test_set_iam_policy_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_policy_pb2.SetIamPolicyRequest()
request.resource = 'resource/value'
# Mock the a... | we expect.
assert isinstance(response, policy_pb2.Policy)
assert response.version == 774
assert response.etag == b'etag_blob'
@pytest.mark.asyncio
async def test_set_iam_policy_async_from_dict():
await test_set_iam_policy_async(request_type=dict)
def test_set_iam_policy_field_headers():
| 69 | 69 | 230 | 9 | 60 | 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 | test_set_iam_policy_field_headers | 4,367 | 4,395 | 4,367 | 4,367 | 5732f557e80d53b3ccb8d38292fb73836248620d | bigcode/the-stack | train |
8fe74136b6f78392ed1a6237 | train | function | def test_list_service_account_keys_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.list_service_account_keys),
'__call__... | def test_list_service_account_keys_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.list_service_account_keys),
'__call__') as call:
# Designate an appropriate r... | ]
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_list_service_account_keys_flattened():
| 66 | 66 | 223 | 10 | 56 | 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_flattened | test_list_service_account_keys_flattened | 2,527 | 2,550 | 2,527 | 2,527 | 8bcb8d12eaa206b8ddbbb24b9fd906455c4661c0 | bigcode/the-stack | train |
68c0ba48aca0e71188f3c730 | train | function | def test_create_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.create_service_account),
'__call__') as ... | def test_create_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.create_service_account),
'__call__') as call:
# Designate an appropriate retu... | .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_flattened():
| 69 | 69 | 230 | 9 | 60 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_flattened | test_create_service_account_flattened | 1,260 | 1,285 | 1,260 | 1,260 | 65bd6612f30b72df832b9f1e789a7331035e5478 | bigcode/the-stack | train |
293e0f97817df07c7a7144b5 | train | function | @pytest.mark.asyncio
async def test_upload_service_account_key_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.... | @pytest.mark.asyncio
async def test_upload_service_account_key_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.UploadServiceAccountKeyRequest()
request.name = 'name/value'
# Mock the actu... | ]
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_upload_service_account_key_field_headers_async():
| 72 | 72 | 241 | 16 | 56 | 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_field_headers_async | test_upload_service_account_key_field_headers_async | 3,284 | 3,313 | 3,284 | 3,285 | 4c38d7135dd77213b5c789caa9abe07de3bddfe9 | bigcode/the-stack | train |
30bead894dac81fc38fc7dd7 | train | function | @pytest.mark.asyncio
async def test_create_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.create_service... | @pytest.mark.asyncio
async def test_create_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.create_service_account),
'__call__') as call:
# Designate an appropriate... | request object and flattened
# fields is an error.
with pytest.raises(ValueError):
client.create_service_account(
iam.CreateServiceAccountRequest(),
name='name_value',
account_id='account_id_value',
service_account=iam.ServiceAccount(name='name_value'),
... | 76 | 76 | 255 | 16 | 60 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_create_service_account_flattened_async | test_create_service_account_flattened_async | 1,304 | 1,332 | 1,304 | 1,305 | 79ed084e5f5983559c85616a595b39b344a9324d | bigcode/the-stack | train |
7b147232a7630d1e603087c7 | train | function | def test_iam_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_file are None.
with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.iam.admin_v1.services.iam.transports.IAMTransport._prep_wrapped_messages') as Transport:
... | def test_iam_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_file are None.
| with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.iam.admin_v1.services.iam.transports.IAMTransport._prep_wrapped_messages') as Transport:
Transport.return_value = None
adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transpo... | )
load_creds.assert_called_once_with("credentials.json", scopes=(
'https://www.googleapis.com/auth/cloud-platform',
),
quota_project_id="octopus",
)
def test_iam_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_fil... | 64 | 64 | 105 | 25 | 39 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_iam_base_transport_with_adc | test_iam_base_transport_with_adc | 6,880 | 6,886 | 6,880 | 6,881 | 17e3a66b40d5c52788f173a2612a2e4cc2fa3f39 | bigcode/the-stack | train |
fec681d1d20946341cfecdc2 | train | function | @pytest.mark.asyncio
async def test_get_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.GetRoleRequest()
... | @pytest.mark.asyncio
async def test_get_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.GetRoleRequest()
request.name = 'name/value'
# Mock the actual call within t... | 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_get_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_get_role_field_headers_async | test_get_role_field_headers_async | 5,542 | 5,571 | 5,542 | 5,543 | 9f13a6410bdd94fa9232b6e93003a2cd7397f2e8 | bigcode/the-stack | train |
50c8b8ab0a9c7728fea19645 | train | function | @pytest.mark.asyncio
async def test_list_service_accounts_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.list_service_accounts... | @pytest.mark.asyncio
async def test_list_service_accounts_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.list_service_accounts),
'__call__', new_callable=mock.AsyncMock) as call:
... | (
accounts=[
iam.ServiceAccount(),
iam.ServiceAccount(),
],
),
RuntimeError,
)
pages = list(client.list_service_accounts(request={}).pages)
for page_, token in zip(pages, ['abc','def','ghi', '']):
... | 83 | 83 | 278 | 15 | 67 | 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_pager | test_list_service_accounts_async_pager | 722 | 768 | 722 | 723 | 323bb5afc389d38b1548efb3eaa1fa60e43d9140 | bigcode/the-stack | train |
ef5a9af1fa432384b07572e5 | train | function | def test_list_roles(transport: str = 'grpc', request_type=iam.ListRolesRequest):
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_list_roles(transport: str = 'grpc', request_type=iam.ListRolesRequest):
| 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... | async for page_ in (await client.query_grantable_roles(request={})).pages:
pages.append(page_)
for page_, token in zip(pages, ['abc','def','ghi', '']):
assert page_.raw_page.next_page_token == token
def test_list_roles(transport: str = 'grpc', request_type=iam.ListRolesRequest):
| 74 | 74 | 247 | 20 | 53 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_list_roles | test_list_roles | 5,130 | 5,157 | 5,130 | 5,130 | 451ac54f4c8c4a56bf11be41d1bdb178bfe3b7a8 | bigcode/the-stack | train |
555ddbb46b6cccddb11e7cd6 | train | function | def test_query_testable_permissions_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_testable_permissions),
'__call__') a... | def test_query_testable_permissions_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_testable_permissions),
'__call__') as call:
# Set the response to a serie... | RuntimeError,
)
metadata = ()
pager = client.query_testable_permissions(request={})
assert pager._metadata == metadata
results = [i for i in pager]
assert len(results) == 6
assert all(isinstance(i, iam.Permission)
for i in results)
def test_... | 71 | 71 | 237 | 8 | 63 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_query_testable_permissions_pages | test_query_testable_permissions_pages | 6,410 | 6,449 | 6,410 | 6,410 | 2539e4c7ae6b5058babd9315a2ef68e806845fff | bigcode/the-stack | train |
c792d7ee2a6af3e6e46788bb | train | function | def test_create_role(transport: str = 'grpc', request_type=iam.CreateRoleRequest):
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_create_role(transport: str = 'grpc', request_type=iam.CreateRoleRequest):
| 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... | 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 (
'x-goog-request-params',
'name=name/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_create_role | test_create_role | 5,574 | 5,613 | 5,574 | 5,574 | dc574d7609c1dc35acc237bd130622be8820ca70 | bigcode/the-stack | train |
220ef5b6844234fd9a4c73a5 | train | function | def test_create_service_account_key(transport: str = 'grpc', request_type=iam.CreateServiceAccountKeyRequest):
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_create_service_account_key(transport: str = 'grpc', request_type=iam.CreateServiceAccountKeyRequest):
| 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... | .asyncio
async def test_get_service_account_key_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 c... | 130 | 130 | 434 | 24 | 106 | 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 | test_create_service_account_key | 2,874 | 2,913 | 2,874 | 2,874 | f7a919771b308c3b2fd8008f9739202131141f37 | bigcode/the-stack | train |
040010375a60f2eb5c393a36 | train | function | def test_get_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.GetRoleRequest()
request.name = 'name/value'
#... | def test_get_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.GetRoleRequest()
request.name = 'name/value'
# Mock the actual call within the gR... | _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_get_role_async_from_dict():
await test_get_role_async(request_type=dict)
def test_get_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_get_role_field_headers | test_get_role_field_headers | 5,511 | 5,539 | 5,511 | 5,511 | 3bb33ea392957da45354176325d8bf9513c2d6f8 | bigcode/the-stack | train |
7a69f88440feb1332a5d8e0d | train | function | def test_get_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.get_iam_policy(
iam_pol... | def test_get_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.get_iam_policy(
iam_policy_pb2.GetIamPolicyRequest(),
... | # 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_get_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_get_iam_policy_flattened_error | test_get_iam_policy_flattened_error | 4,219 | 4,230 | 4,219 | 4,219 | a0322ca74b01f2645915c59ad7c65c412eee574d | bigcode/the-stack | train |
b2fa06f69100b34e557285f9 | train | function | def test_create_service_account_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.CreateServiceAccountRequest()
request... | def test_create_service_account_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.CreateServiceAccountRequest()
request.name = 'name/value'
# Mock the actual call ... | '
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_create_service_account_async_from_dict():
await test_create_service_account_async(request_type=dict)
def test_create_se... | 66 | 66 | 222 | 8 | 58 | 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 | test_create_service_account_field_headers | 1,197 | 1,225 | 1,197 | 1,197 | 88b2ee94a3cec64a05ab00e93609de983818ca41 | bigcode/the-stack | train |
eae5c679336b16bf7e38e4f0 | train | function | def test__get_default_mtls_endpoint():
api_endpoint = "example.googleapis.com"
api_mtls_endpoint = "example.mtls.googleapis.com"
sandbox_endpoint = "example.sandbox.googleapis.com"
sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
non_googleapi = "api.example.com"
assert IAMClient._... | def test__get_default_mtls_endpoint():
| api_endpoint = "example.googleapis.com"
api_mtls_endpoint = "example.mtls.googleapis.com"
sandbox_endpoint = "example.sandbox.googleapis.com"
sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
non_googleapi = "api.example.com"
assert IAMClient._get_default_mtls_endpoint(None) is None... | 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):
return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT
def test__get_default_mtls_endpoint... | 64 | 64 | 183 | 9 | 54 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test__get_default_mtls_endpoint | test__get_default_mtls_endpoint | 75 | 87 | 75 | 75 | 3eec45c789fd794bca31555739ae0ef8b7875246 | bigcode/the-stack | train |
a5455033bbacb56f79e9b582 | train | function | def test_test_iam_permissions_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.test_iam_permissions(
... | def test_test_iam_permissions_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.test_iam_permissions(
iam_policy_pb2.TestIamPermissionsRequest(),
... | # request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].resource == 'resource_value'
assert args[0].permissions == ['permissions_value']
def test_test_iam_permissions_flattened_error():
| 64 | 64 | 89 | 11 | 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_error | test_test_iam_permissions_flattened_error | 4,721 | 4,733 | 4,721 | 4,721 | 77d7da2d2a1d5e80466ac71c62376a5e38c8e13b | bigcode/the-stack | train |
5f87837f9ec0b0591598f670 | train | function | def test_get_iam_policy_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_policy_pb2.GetIamPolicyRequest()
request.reso... | def test_get_iam_policy_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_policy_pb2.GetIamPolicyRequest()
request.resource = 'resource/value'
# Mock the a... | we expect.
assert isinstance(response, policy_pb2.Policy)
assert response.version == 774
assert response.etag == b'etag_blob'
@pytest.mark.asyncio
async def test_get_iam_policy_async_from_dict():
await test_get_iam_policy_async(request_type=dict)
def test_get_iam_policy_field_headers():
| 69 | 69 | 230 | 9 | 60 | googleapis/googleapis-gen | google/iam/admin/v1/iam-admin-v1-py/tests/unit/gapic/admin_v1/test_iam.py | Python | test_get_iam_policy_field_headers | test_get_iam_policy_field_headers | 4,115 | 4,143 | 4,115 | 4,115 | 635aeb5ebaa9d4596a6bb6d3e69ab3df4f35b906 | bigcode/the-stack | train |
211b54af67eb1c6cc53a74f4 | train | function | def test_list_service_accounts_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.list_service_accounts),
'__call__') as ca... | def test_list_service_accounts_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.list_service_accounts),
'__call__') as call:
# Designate an appropriate retur... | 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_list_service_accounts_flattened():
| 64 | 64 | 181 | 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_accounts_flattened | test_list_service_accounts_flattened | 548 | 569 | 548 | 548 | 3022edb44af40ce5a40d1ae0bf8ee104fc0076ff | bigcode/the-stack | train |
81ea01154e30a887961882f4 | train | function | def test_delete_service_account(transport: str = 'grpc', request_type=iam.DeleteServiceAccountRequest):
client = IAMClient(
credentials=ga_credentials.AnonymousCredentials(),
transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
# and we are mocki... | def test_delete_service_account(transport: str = 'grpc', request_type=iam.DeleteServiceAccountRequest):
| 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... | sent.
_, _, kw = call.mock_calls[0]
assert (
'x-goog-request-params',
'service_account.name=service_account.name/value',
) in kw['metadata']
def test_delete_service_account(transport: str = 'grpc', request_type=iam.DeleteServiceAccountRequest):
| 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_delete_service_account | test_delete_service_account | 1,718 | 1,742 | 1,718 | 1,718 | 64fd219c0e0b24afb0225f38586da85cde399115 | bigcode/the-stack | train |
0a5770e6db5483a40ba811e2 | train | function | def test_upload_service_account_key(transport: str = 'grpc', request_type=iam.UploadServiceAccountKeyRequest):
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_upload_service_account_key(transport: str = 'grpc', request_type=iam.UploadServiceAccountKeyRequest):
| 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 = 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.create_service_account_key(
iam.CreateServiceAccountKey... | 130 | 130 | 434 | 24 | 106 | 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 | test_upload_service_account_key | 3,141 | 3,180 | 3,141 | 3,141 | 3e61e4de6d6453b402484077f6ab6d434683b7dd | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.