# Path: tests/unit/v1/test__helpers.py
# class AsyncIter:
#     """Utility to help recreate the effect of an async generator. Useful when
#     you need to mock a system that requires `async for`.
#     """
# 
#     def __init__(self, items):
#         self.items = items
# 
#     async def __aiter__(self):
#         for i in self.items:
#             yield i
# 
# Path: tests/unit/v1/test__helpers.py
# class AsyncMock(mock.MagicMock):
#     async def __call__(self, *args, **kwargs):
#         return super(AsyncMock, self).__call__(*args, **kwargs)


import datetime
import types
import mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncIter
from tests.unit.v1.test__helpers import AsyncMock
    from google.cloud.firestore_v1.async_client import AsyncClient
    from google.cloud.firestore_v1.async_client import _CLIENT_INFO
    from google.cloud.firestore_v1.async_client import DEFAULT_DATABASE
    from google.api_core.client_options import ClientOptions
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.async_document import DocumentSnapshot
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.base_client import _BAD_DOC_TEMPLATE
    from google.cloud.firestore_v1.bulk_writer import BulkWriter
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
    from google.cloud.firestore_v1.async_transaction import AsyncTransaction
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import document
    from google.cloud._helpers import _datetime_to_pb_timestamp
    from google.cloud.firestore_v1 import _helpers
            ),
        )

        collection_2_results.append(
            firestore.RunQueryResponse(
                document=document.Document(name=f"{collection_2_id}/{index}"),
            ),
        )

    col_1_chunks = [
        collection_1_results[:3],
        collection_1_results[3:6],
        collection_1_results[6:9],
        collection_1_results[9:],
    ]

    col_2_chunks = [
        collection_2_results[:3],
        collection_2_results[3:6],
        collection_2_results[6:9],
        collection_2_results[9:],
    ]

    async def _get_chunk(*args, **kwargs):
        start_at = (
            kwargs["request"]["structured_query"].start_at.values[0].reference_value
        )

        if collection_1_id in start_at:
            return AsyncIter(col_1_chunks.pop(0))

# Path: tests/unit/v1/test__helpers.py
# class AsyncIter:
#     """Utility to help recreate the effect of an async generator. Useful when
#     you need to mock a system that requires `async for`.
#     """
# 
#     def __init__(self, items):
#         self.items = items
# 
#     async def __aiter__(self):
#         for i in self.items:
#             yield i
# 
# Path: tests/unit/v1/test__helpers.py
# class AsyncMock(mock.MagicMock):
#     async def __call__(self, *args, **kwargs):
#         return super(AsyncMock, self).__call__(*args, **kwargs)


# Path: tests/unit/v1/test_async_client.py
import datetime
import types
import mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncIter
from tests.unit.v1.test__helpers import AsyncMock
    from google.cloud.firestore_v1.async_client import AsyncClient
    from google.cloud.firestore_v1.async_client import _CLIENT_INFO
    from google.cloud.firestore_v1.async_client import DEFAULT_DATABASE
    from google.api_core.client_options import ClientOptions
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.async_document import DocumentSnapshot
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.base_client import _BAD_DOC_TEMPLATE
    from google.cloud.firestore_v1.bulk_writer import BulkWriter
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
    from google.cloud.firestore_v1.async_transaction import AsyncTransaction
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import document
    from google.cloud._helpers import _datetime_to_pb_timestamp
    from google.cloud.firestore_v1 import _helpers

            ),
        )

        collection_2_results.append(
            firestore.RunQueryResponse(
                document=document.Document(name=f"{collection_2_id}/{index}"),
            ),
        )

    col_1_chunks = [
        collection_1_results[:3],
        collection_1_results[3:6],
        collection_1_results[6:9],
        collection_1_results[9:],
    ]

    col_2_chunks = [
        collection_2_results[:3],
        collection_2_results[3:6],
        collection_2_results[6:9],
        collection_2_results[9:],
    ]

    async def _get_chunk(*args, **kwargs):
        start_at = (
            kwargs["request"]["structured_query"].start_at.values[0].reference_value
        )

        if collection_1_id in start_at:
            return AsyncIter(col_1_chunks.pop(0))

        return AsyncIter(col_2_chunks.pop(0))