# Path: google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py
# class PredictPager:
# class PredictAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., prediction_service.PredictResponse],
#         request: prediction_service.PredictRequest,
#         response: prediction_service.PredictResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[prediction_service.PredictResponse]:
#     def __iter__(self) -> Iterator[prediction_service.PredictResponse.PredictionResult]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[prediction_service.PredictResponse]],
#         request: prediction_service.PredictRequest,
#         response: prediction_service.PredictResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[prediction_service.PredictResponse]:
#     def __aiter__(
#         self,
#     ) -> AsyncIterator[prediction_service.PredictResponse.PredictionResult]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/recommendationengine_v1beta1/types/catalog.py
# class CatalogItem(proto.Message):
#     class CategoryHierarchy(proto.Message):
# class ProductCatalogItem(proto.Message):
#     class StockState(proto.Enum):
#     class ExactPrice(proto.Message):
#     class PriceRange(proto.Message):
# class Image(proto.Message):
#         STOCK_STATE_UNSPECIFIED = 0
#         IN_STOCK = 0
#         OUT_OF_STOCK = 1
#         PREORDER = 2
#         BACKORDER = 3
# 
# Path: google/cloud/recommendationengine_v1beta1/types/common.py
# class FeatureMap(proto.Message):
#     class StringList(proto.Message):
#     class FloatList(proto.Message):
# 
# Path: google/cloud/recommendationengine_v1beta1/types/prediction_service.py
# class PredictRequest(proto.Message):
# class PredictResponse(proto.Message):
#     class PredictionResult(proto.Message):
#     def raw_page(self):
# 
# Path: google/cloud/recommendationengine_v1beta1/types/user_event.py
# class UserEvent(proto.Message):
#     class EventSource(proto.Enum):
# class UserInfo(proto.Message):
# class EventDetail(proto.Message):
# class ProductEventDetail(proto.Message):
# class PurchaseTransaction(proto.Message):
# class ProductDetail(proto.Message):
#         EVENT_SOURCE_UNSPECIFIED = 0
#         AUTOML = 1
#         ECOMMERCE = 2
#         BATCH_UPLOAD = 3


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 gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    PredictionServiceAsyncClient,
)
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    PredictionServiceClient,
)
from google.cloud.recommendationengine_v1beta1.services.prediction_service import pagers
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    transports,
)
from google.cloud.recommendationengine_v1beta1.types import catalog
from google.cloud.recommendationengine_v1beta1.types import common
from google.cloud.recommendationengine_v1beta1.types import prediction_service
from google.cloud.recommendationengine_v1beta1.types import user_event as gcr_user_event
from google.oauth2 import service_account
from google.protobuf import struct_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore
        )


@pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,])
def test_predict(request_type, transport: str = "grpc"):
    client = PredictionServiceClient(
        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.predict), "__call__") as call:
        # Designate an appropriate return value for the call.
        call.return_value = prediction_service.PredictResponse(
            recommendation_token="recommendation_token_value",
            items_missing_in_catalog=["items_missing_in_catalog_value"],
            dry_run=True,
            next_page_token="next_page_token_value",
        )
        response = client.predict(request)

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

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

# Path: google/cloud/recommendationengine_v1beta1/services/prediction_service/pagers.py
# class PredictPager:
# class PredictAsyncPager:
#     def __init__(
#         self,
#         method: Callable[..., prediction_service.PredictResponse],
#         request: prediction_service.PredictRequest,
#         response: prediction_service.PredictResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     def pages(self) -> Iterator[prediction_service.PredictResponse]:
#     def __iter__(self) -> Iterator[prediction_service.PredictResponse.PredictionResult]:
#     def __repr__(self) -> str:
#     def __init__(
#         self,
#         method: Callable[..., Awaitable[prediction_service.PredictResponse]],
#         request: prediction_service.PredictRequest,
#         response: prediction_service.PredictResponse,
#         *,
#         metadata: Sequence[Tuple[str, str]] = ()
#     ):
#     def __getattr__(self, name: str) -> Any:
#     async def pages(self) -> AsyncIterator[prediction_service.PredictResponse]:
#     def __aiter__(
#         self,
#     ) -> AsyncIterator[prediction_service.PredictResponse.PredictionResult]:
#         async def async_generator():
#     def __repr__(self) -> str:
# 
# Path: google/cloud/recommendationengine_v1beta1/types/catalog.py
# class CatalogItem(proto.Message):
#     class CategoryHierarchy(proto.Message):
# class ProductCatalogItem(proto.Message):
#     class StockState(proto.Enum):
#     class ExactPrice(proto.Message):
#     class PriceRange(proto.Message):
# class Image(proto.Message):
#         STOCK_STATE_UNSPECIFIED = 0
#         IN_STOCK = 0
#         OUT_OF_STOCK = 1
#         PREORDER = 2
#         BACKORDER = 3
# 
# Path: google/cloud/recommendationengine_v1beta1/types/common.py
# class FeatureMap(proto.Message):
#     class StringList(proto.Message):
#     class FloatList(proto.Message):
# 
# Path: google/cloud/recommendationengine_v1beta1/types/prediction_service.py
# class PredictRequest(proto.Message):
# class PredictResponse(proto.Message):
#     class PredictionResult(proto.Message):
#     def raw_page(self):
# 
# Path: google/cloud/recommendationengine_v1beta1/types/user_event.py
# class UserEvent(proto.Message):
#     class EventSource(proto.Enum):
# class UserInfo(proto.Message):
# class EventDetail(proto.Message):
# class ProductEventDetail(proto.Message):
# class PurchaseTransaction(proto.Message):
# class ProductDetail(proto.Message):
#         EVENT_SOURCE_UNSPECIFIED = 0
#         AUTOML = 1
#         ECOMMERCE = 2
#         BATCH_UPLOAD = 3


# Path: tests/unit/gapic/recommendationengine_v1beta1/test_prediction_service.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 gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    PredictionServiceAsyncClient,
)
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    PredictionServiceClient,
)
from google.cloud.recommendationengine_v1beta1.services.prediction_service import pagers
from google.cloud.recommendationengine_v1beta1.services.prediction_service import (
    transports,
)
from google.cloud.recommendationengine_v1beta1.types import catalog
from google.cloud.recommendationengine_v1beta1.types import common
from google.cloud.recommendationengine_v1beta1.types import prediction_service
from google.cloud.recommendationengine_v1beta1.types import user_event as gcr_user_event
from google.oauth2 import service_account
from google.protobuf import struct_pb2  # type: ignore
from google.protobuf import timestamp_pb2  # type: ignore

        )


@pytest.mark.parametrize("request_type", [prediction_service.PredictRequest, dict,])
def test_predict(request_type, transport: str = "grpc"):
    client = PredictionServiceClient(
        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.predict), "__call__") as call:
        # Designate an appropriate return value for the call.
        call.return_value = prediction_service.PredictResponse(
            recommendation_token="recommendation_token_value",
            items_missing_in_catalog=["items_missing_in_catalog_value"],
            dry_run=True,
            next_page_token="next_page_token_value",
        )
        response = client.predict(request)

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

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

    assert isinstance(response, pagers.PredictPager)