# 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
    assert isinstance(document2, AsyncDocumentReference)


def test_asyncclient_document_factory_w_absolute_path():

    parts = ("rooms", "roomA")
    client = _make_default_async_client()
    doc_path = "/".join(parts)
    to_match = client.document(doc_path)
    document1 = client.document(to_match._document_path)

    assert document1._path == parts
    assert document1._client is client
    assert isinstance(document1, AsyncDocumentReference)


def test_asyncclient_document_factory_w_nested_path():

    client = _make_default_async_client()
    parts = ("rooms", "roomA", "shoes", "dressy")
    doc_path = "/".join(parts)
    document1 = client.document(doc_path)

    assert document1._path == parts
    assert document1._client is client
    assert isinstance(document1, AsyncDocumentReference)

    # Make sure using segments gives the same result.
    document2 = client.document(*parts)
    assert document2._path == parts

# 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

    assert isinstance(document2, AsyncDocumentReference)


def test_asyncclient_document_factory_w_absolute_path():

    parts = ("rooms", "roomA")
    client = _make_default_async_client()
    doc_path = "/".join(parts)
    to_match = client.document(doc_path)
    document1 = client.document(to_match._document_path)

    assert document1._path == parts
    assert document1._client is client
    assert isinstance(document1, AsyncDocumentReference)


def test_asyncclient_document_factory_w_nested_path():

    client = _make_default_async_client()
    parts = ("rooms", "roomA", "shoes", "dressy")
    doc_path = "/".join(parts)
    document1 = client.document(doc_path)

    assert document1._path == parts
    assert document1._client is client
    assert isinstance(document1, AsyncDocumentReference)

    # Make sure using segments gives the same result.
    document2 = client.document(*parts)
    assert document2._path == parts

    assert document2._client is client