# 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_base_query.py
# def _make_credentials():
#     import google.auth.credentials
# 
#     return mock.Mock(spec=google.auth.credentials.Credentials)
# 
# Path: tests/unit/v1/test_base_query.py
# def _make_query_response(**kwargs):
#     # kwargs supported are ``skipped_results``, ``name`` and ``data``
#     from google.cloud.firestore_v1.types import document
#     from google.cloud.firestore_v1.types import firestore
#     from google.cloud._helpers import _datetime_to_pb_timestamp
#     from google.cloud.firestore_v1 import _helpers
# 
#     now = datetime.datetime.utcnow()
#     read_time = _datetime_to_pb_timestamp(now)
#     kwargs["read_time"] = read_time
# 
#     name = kwargs.pop("name", None)
#     data = kwargs.pop("data", None)
#     if name is not None and data is not None:
#         document_pb = document.Document(name=name, fields=_helpers.encode_dict(data))
#         delta = datetime.timedelta(seconds=100)
#         update_time = _datetime_to_pb_timestamp(now - delta)
#         create_time = _datetime_to_pb_timestamp(now - 2 * delta)
#         document_pb._pb.update_time.CopyFrom(update_time)
#         document_pb._pb.create_time.CopyFrom(create_time)
# 
#         kwargs["document"] = document_pb
# 
#     return firestore.RunQueryResponse(**kwargs)
# 
# Path: tests/unit/v1/test_base_query.py
# def _make_cursor_pb(pair):
#     from google.cloud.firestore_v1 import _helpers
#     from google.cloud.firestore_v1.types import query
# 
#     values, before = pair
#     value_pbs = [_helpers.encode_value(value) for value in values]
#     return query.Cursor(values=value_pbs, before=before)


import types
import mock
import pytest
from tests.unit.v1.test__helpers import AsyncIter
from tests.unit.v1.test__helpers import AsyncMock
from tests.unit.v1.test_base_query import _make_credentials
from tests.unit.v1.test_base_query import _make_query_response
from tests.unit.v1.test_base_query import _make_cursor_pb
    from google.cloud.firestore_v1.async_query import AsyncQuery
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud import firestore
    from google.cloud.firestore_v1.base_query import _enum_from_direction
    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 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_query import AsyncCollectionGroup
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_client import AsyncClient
    snapshot = returned[0]
    to_match = other.document("bark")
    assert snapshot.reference._document_path == to_match._document_path
    assert snapshot.to_dict() == data

    # Verify the mock call.
    parent_path, _ = parent._parent_info()
    firestore_api.run_query.assert_called_once_with(
        request={
            "parent": parent_path,
            "structured_query": query._to_protobuf(),
            "transaction": None,
        },
        metadata=client._rpc_metadata,
    )


def _make_async_collection_group(*args, **kwargs):

    return AsyncCollectionGroup(*args, **kwargs)


def test_asynccollectiongroup_constructor():
    query = _make_async_collection_group(mock.sentinel.parent)
    assert query._parent is mock.sentinel.parent
    assert query._projection is None
    assert query._field_filters == ()
    assert query._orders == ()
    assert query._limit is None
    assert query._offset is None

# 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_base_query.py
# def _make_credentials():
#     import google.auth.credentials
# 
#     return mock.Mock(spec=google.auth.credentials.Credentials)
# 
# Path: tests/unit/v1/test_base_query.py
# def _make_query_response(**kwargs):
#     # kwargs supported are ``skipped_results``, ``name`` and ``data``
#     from google.cloud.firestore_v1.types import document
#     from google.cloud.firestore_v1.types import firestore
#     from google.cloud._helpers import _datetime_to_pb_timestamp
#     from google.cloud.firestore_v1 import _helpers
# 
#     now = datetime.datetime.utcnow()
#     read_time = _datetime_to_pb_timestamp(now)
#     kwargs["read_time"] = read_time
# 
#     name = kwargs.pop("name", None)
#     data = kwargs.pop("data", None)
#     if name is not None and data is not None:
#         document_pb = document.Document(name=name, fields=_helpers.encode_dict(data))
#         delta = datetime.timedelta(seconds=100)
#         update_time = _datetime_to_pb_timestamp(now - delta)
#         create_time = _datetime_to_pb_timestamp(now - 2 * delta)
#         document_pb._pb.update_time.CopyFrom(update_time)
#         document_pb._pb.create_time.CopyFrom(create_time)
# 
#         kwargs["document"] = document_pb
# 
#     return firestore.RunQueryResponse(**kwargs)
# 
# Path: tests/unit/v1/test_base_query.py
# def _make_cursor_pb(pair):
#     from google.cloud.firestore_v1 import _helpers
#     from google.cloud.firestore_v1.types import query
# 
#     values, before = pair
#     value_pbs = [_helpers.encode_value(value) for value in values]
#     return query.Cursor(values=value_pbs, before=before)


# Path: tests/unit/v1/test_async_query.py
import types
import mock
import pytest
from tests.unit.v1.test__helpers import AsyncIter
from tests.unit.v1.test__helpers import AsyncMock
from tests.unit.v1.test_base_query import _make_credentials
from tests.unit.v1.test_base_query import _make_query_response
from tests.unit.v1.test_base_query import _make_cursor_pb
    from google.cloud.firestore_v1.async_query import AsyncQuery
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud import firestore
    from google.cloud.firestore_v1.base_query import _enum_from_direction
    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 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_query import AsyncCollectionGroup
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_client import AsyncClient

    snapshot = returned[0]
    to_match = other.document("bark")
    assert snapshot.reference._document_path == to_match._document_path
    assert snapshot.to_dict() == data

    # Verify the mock call.
    parent_path, _ = parent._parent_info()
    firestore_api.run_query.assert_called_once_with(
        request={
            "parent": parent_path,
            "structured_query": query._to_protobuf(),
            "transaction": None,
        },
        metadata=client._rpc_metadata,
    )


def _make_async_collection_group(*args, **kwargs):

    return AsyncCollectionGroup(*args, **kwargs)


def test_asynccollectiongroup_constructor():
    query = _make_async_collection_group(mock.sentinel.parent)
    assert query._parent is mock.sentinel.parent
    assert query._projection is None
    assert query._field_filters == ()
    assert query._orders == ()
    assert query._limit is None
    assert query._offset is None

    assert query._start_at is None