Skip to content

Commit

Permalink
feat: leverage async anonymous credentials in tests (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr authored Aug 26, 2024
1 parent f773c8a commit 4afac87
Show file tree
Hide file tree
Showing 11 changed files with 869 additions and 727 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_delete_operation(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -120,7 +120,7 @@ def test_delete_operation_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -164,7 +164,7 @@ def test_delete_operation_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_cancel_operation(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -249,7 +249,7 @@ def test_cancel_operation_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -293,7 +293,7 @@ def test_cancel_operation_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -335,7 +335,7 @@ def test_wait_operation(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -377,7 +377,7 @@ def test_wait_operation_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -421,7 +421,7 @@ def test_wait_operation_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -464,7 +464,7 @@ def test_get_operation(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -506,7 +506,7 @@ def test_get_operation_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -550,7 +550,7 @@ def test_get_operation_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -593,7 +593,7 @@ def test_list_operations(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -635,7 +635,7 @@ def test_list_operations_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -679,7 +679,7 @@ def test_list_operations_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -728,7 +728,7 @@ def test_list_locations(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -770,7 +770,7 @@ def test_list_locations_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -814,7 +814,7 @@ def test_list_locations_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -859,7 +859,7 @@ def test_get_location(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -900,7 +900,7 @@ def test_get_location_field_headers():
credentials=ga_credentials.AnonymousCredentials())
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials()
credentials=async_anonymous_credentials()
)
{% endif %}

Expand Down Expand Up @@ -944,7 +944,7 @@ def test_get_location_from_dict():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}
# Mock the actual call within the gRPC stub, and fake the request.
Expand Down Expand Up @@ -990,7 +990,7 @@ def test_set_iam_policy(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -1038,7 +1038,7 @@ def test_set_iam_policy_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -1090,7 +1090,7 @@ def test_set_iam_policy_from_dict():
@pytest.mark.asyncio
async def test_set_iam_policy_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call:
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def test_get_iam_policy(transport: str = "grpc"):
@pytest.mark.asyncio
async def test_get_iam_policy_async(transport: str = "grpc_asyncio"):
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)

# Everything is optional in proto3 as far as the runtime is concerned,
Expand Down Expand Up @@ -1202,7 +1202,7 @@ def test_get_iam_policy_field_headers():
@pytest.mark.asyncio
async def test_get_iam_policy_field_headers_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)

# Any value that is part of the HTTP/1.1 URI should be sent as
Expand Down Expand Up @@ -1248,7 +1248,7 @@ def test_get_iam_policy_from_dict():
@pytest.mark.asyncio
async def test_get_iam_policy_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call:
Expand Down Expand Up @@ -1301,7 +1301,7 @@ def test_test_iam_permissions(transport: str = "grpc"):
@pytest.mark.asyncio
async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"):
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)

# Everything is optional in proto3 as far as the runtime is concerned,
Expand Down Expand Up @@ -1362,7 +1362,7 @@ def test_test_iam_permissions_field_headers():
@pytest.mark.asyncio
async def test_test_iam_permissions_field_headers_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)

# Any value that is part of the HTTP/1.1 URI should be sent as
Expand Down Expand Up @@ -1412,7 +1412,7 @@ def test_test_iam_permissions_from_dict():
@pytest.mark.asyncio
async def test_test_iam_permissions_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down Expand Up @@ -1449,7 +1449,7 @@ def test_set_iam_policy(transport: str = "grpc"):
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)
{% endif %}

Expand Down Expand Up @@ -1497,7 +1497,7 @@ def test_set_iam_policy_field_headers():
)
{% else %}
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
{% endif %}

Expand Down Expand Up @@ -1549,7 +1549,7 @@ def test_set_iam_policy_from_dict():
@pytest.mark.asyncio
async def test_set_iam_policy_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call:
Expand Down Expand Up @@ -1601,7 +1601,7 @@ def test_get_iam_policy(transport: str = "grpc"):
@pytest.mark.asyncio
async def test_get_iam_policy_async(transport: str = "grpc_asyncio"):
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)

# Everything is optional in proto3 as far as the runtime is concerned,
Expand Down Expand Up @@ -1662,7 +1662,7 @@ def test_get_iam_policy_field_headers():
@pytest.mark.asyncio
async def test_get_iam_policy_field_headers_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)

# Any value that is part of the HTTP/1.1 URI should be sent as
Expand Down Expand Up @@ -1708,7 +1708,7 @@ def test_get_iam_policy_from_dict():
@pytest.mark.asyncio
async def test_get_iam_policy_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call:
Expand Down Expand Up @@ -1762,7 +1762,7 @@ def test_test_iam_permissions(transport: str = "grpc"):
@pytest.mark.asyncio
async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"):
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
credentials=async_anonymous_credentials(), transport=transport,
)

# Everything is optional in proto3 as far as the runtime is concerned,
Expand Down Expand Up @@ -1823,7 +1823,7 @@ def test_test_iam_permissions_field_headers():
@pytest.mark.asyncio
async def test_test_iam_permissions_field_headers_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)

# Any value that is part of the HTTP/1.1 URI should be sent as
Expand Down Expand Up @@ -1873,7 +1873,7 @@ def test_test_iam_permissions_from_dict():
@pytest.mark.asyncio
async def test_test_iam_permissions_from_dict_async():
client = {{ service.async_client_name }}(
credentials=ga_credentials.AnonymousCredentials(),
credentials=async_anonymous_credentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand Down
Loading

0 comments on commit 4afac87

Please sign in to comment.