# Path: google/cloud/orchestration/airflow/service_v1/services/environments/pagers.py
# class ListEnvironmentsPager:
# class ListEnvironmentsAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., environments.ListEnvironmentsResponse],
#         request: environments.ListEnvironmentsRequest,
#         response: environments.ListEnvironmentsResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[environments.ListEnvironmentsResponse]:
#     def __iter__(self) -> Iterator[environments.Environment]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[environments.ListEnvironmentsResponse]],
#         request: environments.ListEnvironmentsRequest,
#         response: environments.ListEnvironmentsResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[environments.ListEnvironmentsResponse]:
#     def __aiter__(self) -> AsyncIterator[environments.Environment]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/orchestration/airflow/service_v1/types/environments.py
# class CreateEnvironmentRequest(proto.Message):
# class GetEnvironmentRequest(proto.Message):
# class ListEnvironmentsRequest(proto.Message):
# class ListEnvironmentsResponse(proto.Message):
# class DeleteEnvironmentRequest(proto.Message):
# class UpdateEnvironmentRequest(proto.Message):
# class EnvironmentConfig(proto.Message):
# class WebServerNetworkAccessControl(proto.Message):
#     class AllowedIpRange(proto.Message):
# class DatabaseConfig(proto.Message):
# class WebServerConfig(proto.Message):
# class EncryptionConfig(proto.Message):
# class SoftwareConfig(proto.Message):
# class IPAllocationPolicy(proto.Message):
# class NodeConfig(proto.Message):
# class PrivateClusterConfig(proto.Message):
# class PrivateEnvironmentConfig(proto.Message):
# class Environment(proto.Message):
#     class State(proto.Enum):
# class CheckUpgradeResponse(proto.Message):
#     class ConflictResult(proto.Enum):
#     def raw_page(self):
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         RUNNING = 2
#         UPDATING = 3
#         DELETING = 4
#         ERROR = 5
#         CONFLICT_RESULT_UNSPECIFIED = 0
#         CONFLICT = 1
#         NO_CONFLICT = 2
# 
# Path: google/cloud/orchestration/airflow/service_v1/types/operations.py
# class OperationMetadata(proto.Message):
#     class State(proto.Enum):
#     class Type(proto.Enum):
#         STATE_UNSPECIFIED = 0
#         PENDING = 1
#         RUNNING = 2
#         SUCCEEDED = 3
#         SUCCESSFUL = 3
#         FAILED = 4
#         TYPE_UNSPECIFIED = 0
#         CREATE = 1
#         DELETE = 2
#         UPDATE = 3
#         CHECK = 4


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.orchestration.airflow.service_v1.services.environments import (
    EnvironmentsAsyncClient,
)
from google.cloud.orchestration.airflow.service_v1.services.environments import (
    EnvironmentsClient,
)
from google.cloud.orchestration.airflow.service_v1.services.environments import pagers
from google.cloud.orchestration.airflow.service_v1.services.environments import (
    transports,
)
from google.cloud.orchestration.airflow.service_v1.types import environments
from google.cloud.orchestration.airflow.service_v1.types import operations
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
    with mock.patch.object(
        type(client.transport.list_environments), "__call__"
    ) as call:
        # Designate an appropriate return value for the call.
        call.return_value = environments.ListEnvironmentsResponse()

        call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
            environments.ListEnvironmentsResponse()
        )
        # Call the method with a truthy value for each flattened field,
        # using the keyword arguments to the method.
        response = await client.list_environments(parent="parent_value",)

        # Establish that the underlying call was made with the expected
        # request object values.
        assert len(call.mock_calls)
        _, args, _ = call.mock_calls[0]
        arg = args[0].parent
        mock_val = "parent_value"
        assert arg == mock_val


@pytest.mark.asyncio
async def test_list_environments_flattened_error_async():
    client = EnvironmentsAsyncClient(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_environments(

# Path: google/cloud/orchestration/airflow/service_v1/services/environments/pagers.py
# class ListEnvironmentsPager:
# class ListEnvironmentsAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., environments.ListEnvironmentsResponse],
#         request: environments.ListEnvironmentsRequest,
#         response: environments.ListEnvironmentsResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[environments.ListEnvironmentsResponse]:
#     def __iter__(self) -> Iterator[environments.Environment]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[environments.ListEnvironmentsResponse]],
#         request: environments.ListEnvironmentsRequest,
#         response: environments.ListEnvironmentsResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[environments.ListEnvironmentsResponse]:
#     def __aiter__(self) -> AsyncIterator[environments.Environment]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/orchestration/airflow/service_v1/types/environments.py
# class CreateEnvironmentRequest(proto.Message):
# class GetEnvironmentRequest(proto.Message):
# class ListEnvironmentsRequest(proto.Message):
# class ListEnvironmentsResponse(proto.Message):
# class DeleteEnvironmentRequest(proto.Message):
# class UpdateEnvironmentRequest(proto.Message):
# class EnvironmentConfig(proto.Message):
# class WebServerNetworkAccessControl(proto.Message):
#     class AllowedIpRange(proto.Message):
# class DatabaseConfig(proto.Message):
# class WebServerConfig(proto.Message):
# class EncryptionConfig(proto.Message):
# class SoftwareConfig(proto.Message):
# class IPAllocationPolicy(proto.Message):
# class NodeConfig(proto.Message):
# class PrivateClusterConfig(proto.Message):
# class PrivateEnvironmentConfig(proto.Message):
# class Environment(proto.Message):
#     class State(proto.Enum):
# class CheckUpgradeResponse(proto.Message):
#     class ConflictResult(proto.Enum):
#     def raw_page(self):
#         STATE_UNSPECIFIED = 0
#         CREATING = 1
#         RUNNING = 2
#         UPDATING = 3
#         DELETING = 4
#         ERROR = 5
#         CONFLICT_RESULT_UNSPECIFIED = 0
#         CONFLICT = 1
#         NO_CONFLICT = 2
# 
# Path: google/cloud/orchestration/airflow/service_v1/types/operations.py
# class OperationMetadata(proto.Message):
#     class State(proto.Enum):
#     class Type(proto.Enum):
#         STATE_UNSPECIFIED = 0
#         PENDING = 1
#         RUNNING = 2
#         SUCCEEDED = 3
#         SUCCESSFUL = 3
#         FAILED = 4
#         TYPE_UNSPECIFIED = 0
#         CREATE = 1
#         DELETE = 2
#         UPDATE = 3
#         CHECK = 4


# Path: tests/unit/gapic/service_v1/test_environments.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.orchestration.airflow.service_v1.services.environments import (
    EnvironmentsAsyncClient,
)
from google.cloud.orchestration.airflow.service_v1.services.environments import (
    EnvironmentsClient,
)
from google.cloud.orchestration.airflow.service_v1.services.environments import pagers
from google.cloud.orchestration.airflow.service_v1.services.environments import (
    transports,
)
from google.cloud.orchestration.airflow.service_v1.types import environments
from google.cloud.orchestration.airflow.service_v1.types import operations
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

    with mock.patch.object(
        type(client.transport.list_environments), "__call__"
    ) as call:
        # Designate an appropriate return value for the call.
        call.return_value = environments.ListEnvironmentsResponse()

        call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
            environments.ListEnvironmentsResponse()
        )
        # Call the method with a truthy value for each flattened field,
        # using the keyword arguments to the method.
        response = await client.list_environments(parent="parent_value",)

        # Establish that the underlying call was made with the expected
        # request object values.
        assert len(call.mock_calls)
        _, args, _ = call.mock_calls[0]
        arg = args[0].parent
        mock_val = "parent_value"
        assert arg == mock_val


@pytest.mark.asyncio
async def test_list_environments_flattened_error_async():
    client = EnvironmentsAsyncClient(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_environments(

            environments.ListEnvironmentsRequest(), parent="parent_value",