# Path: google/cloud/redis_v1/services/cloud_redis/pagers.py
# class ListInstancesPager:
# class ListInstancesAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., cloud_redis.ListInstancesResponse],
#         request: cloud_redis.ListInstancesRequest,
#         response: cloud_redis.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[cloud_redis.ListInstancesResponse]:
#     def __iter__(self) -> Iterator[cloud_redis.Instance]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[cloud_redis.ListInstancesResponse]],
#         request: cloud_redis.ListInstancesRequest,
#         response: cloud_redis.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[cloud_redis.ListInstancesResponse]:
#     def __aiter__(self) -> AsyncIterator[cloud_redis.Instance]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/redis_v1/types/cloud_redis.py
# class NodeInfo(proto.Message):
# class Instance(proto.Message):
#     class State(proto.Enum):
#     class Tier(proto.Enum):
#     class ConnectMode(proto.Enum):
#     class ReadReplicasMode(proto.Enum):
# class ListInstancesRequest(proto.Message):
# class ListInstancesResponse(proto.Message):
# class GetInstanceRequest(proto.Message):
# class CreateInstanceRequest(proto.Message):
# class UpdateInstanceRequest(proto.Message):
# class UpgradeInstanceRequest(proto.Message):
# class DeleteInstanceRequest(proto.Message):
# class GcsSource(proto.Message):
# class InputConfig(proto.Message):
# class ImportInstanceRequest(proto.Message):
# class GcsDestination(proto.Message):
# class OutputConfig(proto.Message):
# class ExportInstanceRequest(proto.Message):
# class FailoverInstanceRequest(proto.Message):
#     class DataProtectionMode(proto.Enum):
# class OperationMetadata(proto.Message):
# class LocationMetadata(proto.Message):
# class ZoneMetadata(proto.Message):
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         READY = 2
#         UPDATING = 3
#         DELETING = 4
#         REPAIRING = 5
#         MAINTENANCE = 6
#         IMPORTING = 8
#         FAILING_OVER = 9
#         TIER_UNSPECIFIED = 0
#         BASIC = 1
#         STANDARD_HA = 3
#         CONNECT_MODE_UNSPECIFIED = 0
#         DIRECT_PEERING = 1
#         PRIVATE_SERVICE_ACCESS = 2
#         READ_REPLICAS_MODE_UNSPECIFIED = 0
#         READ_REPLICAS_DISABLED = 1
#         READ_REPLICAS_ENABLED = 2
#         DATA_PROTECTION_MODE_UNSPECIFIED = 0
#         LIMITED_DATA_LOSS = 1
#         FORCE_DATA_LOSS = 2
#     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.redis_v1.services.cloud_redis import CloudRedisAsyncClient
from google.cloud.redis_v1.services.cloud_redis import CloudRedisClient
from google.cloud.redis_v1.services.cloud_redis import pagers
from google.cloud.redis_v1.services.cloud_redis import transports
from google.cloud.redis_v1.types import cloud_redis
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
        # Designate an appropriate return value for the call.
        call.return_value = operations_pb2.Operation(name="operations/op")
        # Call the method with a truthy value for each flattened field,
        # using the keyword arguments to the method.
        client.failover_instance(
            name="name_value",
            data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS,
        )

        # Establish that the underlying call was made with the expected
        # request object values.
        assert len(call.mock_calls) == 1
        _, args, _ = call.mock_calls[0]
        arg = args[0].name
        mock_val = "name_value"
        assert arg == mock_val
        arg = args[0].data_protection_mode
        mock_val = (
            cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS
        )
        assert arg == mock_val


def test_failover_instance_flattened_error():
    client = CloudRedisClient(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.failover_instance(

# Path: google/cloud/redis_v1/services/cloud_redis/pagers.py
# class ListInstancesPager:
# class ListInstancesAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., cloud_redis.ListInstancesResponse],
#         request: cloud_redis.ListInstancesRequest,
#         response: cloud_redis.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[cloud_redis.ListInstancesResponse]:
#     def __iter__(self) -> Iterator[cloud_redis.Instance]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[cloud_redis.ListInstancesResponse]],
#         request: cloud_redis.ListInstancesRequest,
#         response: cloud_redis.ListInstancesResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[cloud_redis.ListInstancesResponse]:
#     def __aiter__(self) -> AsyncIterator[cloud_redis.Instance]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/redis_v1/types/cloud_redis.py
# class NodeInfo(proto.Message):
# class Instance(proto.Message):
#     class State(proto.Enum):
#     class Tier(proto.Enum):
#     class ConnectMode(proto.Enum):
#     class ReadReplicasMode(proto.Enum):
# class ListInstancesRequest(proto.Message):
# class ListInstancesResponse(proto.Message):
# class GetInstanceRequest(proto.Message):
# class CreateInstanceRequest(proto.Message):
# class UpdateInstanceRequest(proto.Message):
# class UpgradeInstanceRequest(proto.Message):
# class DeleteInstanceRequest(proto.Message):
# class GcsSource(proto.Message):
# class InputConfig(proto.Message):
# class ImportInstanceRequest(proto.Message):
# class GcsDestination(proto.Message):
# class OutputConfig(proto.Message):
# class ExportInstanceRequest(proto.Message):
# class FailoverInstanceRequest(proto.Message):
#     class DataProtectionMode(proto.Enum):
# class OperationMetadata(proto.Message):
# class LocationMetadata(proto.Message):
# class ZoneMetadata(proto.Message):
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         READY = 2
#         UPDATING = 3
#         DELETING = 4
#         REPAIRING = 5
#         MAINTENANCE = 6
#         IMPORTING = 8
#         FAILING_OVER = 9
#         TIER_UNSPECIFIED = 0
#         BASIC = 1
#         STANDARD_HA = 3
#         CONNECT_MODE_UNSPECIFIED = 0
#         DIRECT_PEERING = 1
#         PRIVATE_SERVICE_ACCESS = 2
#         READ_REPLICAS_MODE_UNSPECIFIED = 0
#         READ_REPLICAS_DISABLED = 1
#         READ_REPLICAS_ENABLED = 2
#         DATA_PROTECTION_MODE_UNSPECIFIED = 0
#         LIMITED_DATA_LOSS = 1
#         FORCE_DATA_LOSS = 2
#     def raw_page(self):


# Path: tests/unit/gapic/redis_v1/test_cloud_redis.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.redis_v1.services.cloud_redis import CloudRedisAsyncClient
from google.cloud.redis_v1.services.cloud_redis import CloudRedisClient
from google.cloud.redis_v1.services.cloud_redis import pagers
from google.cloud.redis_v1.services.cloud_redis import transports
from google.cloud.redis_v1.types import cloud_redis
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

        # Designate an appropriate return value for the call.
        call.return_value = operations_pb2.Operation(name="operations/op")
        # Call the method with a truthy value for each flattened field,
        # using the keyword arguments to the method.
        client.failover_instance(
            name="name_value",
            data_protection_mode=cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS,
        )

        # Establish that the underlying call was made with the expected
        # request object values.
        assert len(call.mock_calls) == 1
        _, args, _ = call.mock_calls[0]
        arg = args[0].name
        mock_val = "name_value"
        assert arg == mock_val
        arg = args[0].data_protection_mode
        mock_val = (
            cloud_redis.FailoverInstanceRequest.DataProtectionMode.LIMITED_DATA_LOSS
        )
        assert arg == mock_val


def test_failover_instance_flattened_error():
    client = CloudRedisClient(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.failover_instance(

            cloud_redis.FailoverInstanceRequest(),