# Path: google/cloud/memcache_v1/services/cloud_memcache/pagers.py
# class ListInstancesPager:
# class ListInstancesAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., cloud_memcache.ListInstancesResponse],
#         request: cloud_memcache.ListInstancesRequest,
#         response: cloud_memcache.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[cloud_memcache.ListInstancesResponse]:
#     def __iter__(self) -> Iterator[cloud_memcache.Instance]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[cloud_memcache.ListInstancesResponse]],
#         request: cloud_memcache.ListInstancesRequest,
#         response: cloud_memcache.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[cloud_memcache.ListInstancesResponse]:
#     def __aiter__(self) -> AsyncIterator[cloud_memcache.Instance]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/memcache_v1/types/cloud_memcache.py
# class MemcacheVersion(proto.Enum):
# class Instance(proto.Message):
#     class State(proto.Enum):
#     class NodeConfig(proto.Message):
#     class Node(proto.Message):
#         class State(proto.Enum):
#     class InstanceMessage(proto.Message):
#         class Code(proto.Enum):
# class ListInstancesRequest(proto.Message):
# class ListInstancesResponse(proto.Message):
# class GetInstanceRequest(proto.Message):
# class CreateInstanceRequest(proto.Message):
# class UpdateInstanceRequest(proto.Message):
# class DeleteInstanceRequest(proto.Message):
# class ApplyParametersRequest(proto.Message):
# class UpdateParametersRequest(proto.Message):
# class MemcacheParameters(proto.Message):
# class OperationMetadata(proto.Message):
#     MEMCACHE_VERSION_UNSPECIFIED = 0
#     MEMCACHE_1_5 = 1
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         READY = 2
#         DELETING = 4
#         PERFORMING_MAINTENANCE = 5
#             STATE_UNSPECIFIED = 0
#             CREATING = 1
#             READY = 2
#             DELETING = 3
#             UPDATING = 4
#             CODE_UNSPECIFIED = 0
#             ZONE_DISTRIBUTION_UNBALANCED = 1
#     def raw_page(self):


import os
import mock
import grpc
import math
import pytest
import google.auth
from grpc.experimental import aio
from proto.marshal.rules.dates import DurationRule, TimestampRule
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
from google.api_core import future
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
from google.api_core import operation
from google.api_core import operation_async  # type: ignore
from google.api_core import operations_v1
from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.memcache_v1.services.cloud_memcache import CloudMemcacheAsyncClient
from google.cloud.memcache_v1.services.cloud_memcache import CloudMemcacheClient
from google.cloud.memcache_v1.services.cloud_memcache import pagers
from google.cloud.memcache_v1.services.cloud_memcache import transports
from google.cloud.memcache_v1.types import cloud_memcache
from google.longrunning import operations_pb2
from google.oauth2 import service_account
from google.protobuf import field_mask_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore

@pytest.mark.asyncio
async def test_list_instances_async(
    transport: str = "grpc_asyncio", request_type=cloud_memcache.ListInstancesRequest
):
    client = CloudMemcacheAsyncClient(
        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 actual call within the gRPC stub, and fake the request.
    with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
        # Designate an appropriate return value for the call.
        call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
            cloud_memcache.ListInstancesResponse(
                next_page_token="next_page_token_value",
                unreachable=["unreachable_value"],
            )
        )
        response = await client.list_instances(request)

        # Establish that the underlying gRPC stub method was called.
        assert len(call.mock_calls)
        _, args, _ = call.mock_calls[0]
        assert args[0] == cloud_memcache.ListInstancesRequest()

    # Establish that the response is the type that we expect.

# Path: google/cloud/memcache_v1/services/cloud_memcache/pagers.py
# class ListInstancesPager:
# class ListInstancesAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., cloud_memcache.ListInstancesResponse],
#         request: cloud_memcache.ListInstancesRequest,
#         response: cloud_memcache.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[cloud_memcache.ListInstancesResponse]:
#     def __iter__(self) -> Iterator[cloud_memcache.Instance]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[cloud_memcache.ListInstancesResponse]],
#         request: cloud_memcache.ListInstancesRequest,
#         response: cloud_memcache.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[cloud_memcache.ListInstancesResponse]:
#     def __aiter__(self) -> AsyncIterator[cloud_memcache.Instance]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/memcache_v1/types/cloud_memcache.py
# class MemcacheVersion(proto.Enum):
# class Instance(proto.Message):
#     class State(proto.Enum):
#     class NodeConfig(proto.Message):
#     class Node(proto.Message):
#         class State(proto.Enum):
#     class InstanceMessage(proto.Message):
#         class Code(proto.Enum):
# class ListInstancesRequest(proto.Message):
# class ListInstancesResponse(proto.Message):
# class GetInstanceRequest(proto.Message):
# class CreateInstanceRequest(proto.Message):
# class UpdateInstanceRequest(proto.Message):
# class DeleteInstanceRequest(proto.Message):
# class ApplyParametersRequest(proto.Message):
# class UpdateParametersRequest(proto.Message):
# class MemcacheParameters(proto.Message):
# class OperationMetadata(proto.Message):
#     MEMCACHE_VERSION_UNSPECIFIED = 0
#     MEMCACHE_1_5 = 1
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         READY = 2
#         DELETING = 4
#         PERFORMING_MAINTENANCE = 5
#             STATE_UNSPECIFIED = 0
#             CREATING = 1
#             READY = 2
#             DELETING = 3
#             UPDATING = 4
#             CODE_UNSPECIFIED = 0
#             ZONE_DISTRIBUTION_UNBALANCED = 1
#     def raw_page(self):


# Path: tests/unit/gapic/memcache_v1/test_cloud_memcache.py
import os
import mock
import grpc
import math
import pytest
import google.auth
from grpc.experimental import aio
from proto.marshal.rules.dates import DurationRule, TimestampRule
from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
from google.api_core import future
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
from google.api_core import operation
from google.api_core import operation_async  # type: ignore
from google.api_core import operations_v1
from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.memcache_v1.services.cloud_memcache import CloudMemcacheAsyncClient
from google.cloud.memcache_v1.services.cloud_memcache import CloudMemcacheClient
from google.cloud.memcache_v1.services.cloud_memcache import pagers
from google.cloud.memcache_v1.services.cloud_memcache import transports
from google.cloud.memcache_v1.types import cloud_memcache
from google.longrunning import operations_pb2
from google.oauth2 import service_account
from google.protobuf import field_mask_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore


@pytest.mark.asyncio
async def test_list_instances_async(
    transport: str = "grpc_asyncio", request_type=cloud_memcache.ListInstancesRequest
):
    client = CloudMemcacheAsyncClient(
        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 actual call within the gRPC stub, and fake the request.
    with mock.patch.object(type(client.transport.list_instances), "__call__") as call:
        # Designate an appropriate return value for the call.
        call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
            cloud_memcache.ListInstancesResponse(
                next_page_token="next_page_token_value",
                unreachable=["unreachable_value"],
            )
        )
        response = await client.list_instances(request)

        # Establish that the underlying gRPC stub method was called.
        assert len(call.mock_calls)
        _, args, _ = call.mock_calls[0]
        assert args[0] == cloud_memcache.ListInstancesRequest()

    # Establish that the response is the type that we expect.

    assert isinstance(response, pagers.ListInstancesAsyncPager)