# 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
# 
# class AsyncMock(mock.MagicMock):
#     async def __call__(self, *args, **kwargs):
#         return super(AsyncMock, self).__call__(*args, **kwargs)


import collections
import mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncIter, AsyncMock
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import DocumentSnapshot
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.transforms import DELETE_FIELD
    from google.api_core.retry import Retry
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import write
    from google.protobuf import timestamp_pb2
    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.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.transaction import Transaction
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_client import AsyncClient


@pytest.mark.asyncio
async def test_asyncdocumentreference_set_w_retry_timeout():

    retry = Retry(predicate=object())
    timeout = 123.0
    await _set_helper(retry=retry, timeout=timeout)


@pytest.mark.asyncio
async def test_asyncdocumentreference_set_merge():
    await _set_helper(merge=True)


def _write_pb_for_update(document_path, update_values, field_paths):

    return write.Write(
        update=document.Document(
            name=document_path, fields=_helpers.encode_dict(update_values)
        ),
        update_mask=common.DocumentMask(field_paths=field_paths),
        current_document=common.Precondition(exists=True),
    )


@pytest.mark.asyncio
async def _update_helper(retry=None, timeout=None, **option_kwargs):

    # Create a minimal fake GAPIC with a dummy response.

# 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
# 
# class AsyncMock(mock.MagicMock):
#     async def __call__(self, *args, **kwargs):
#         return super(AsyncMock, self).__call__(*args, **kwargs)


# Path: tests/unit/v1/test_async_document.py
import collections
import mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncIter, AsyncMock
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_document import AsyncDocumentReference
    from google.cloud.firestore_v1.async_document import DocumentSnapshot
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.types import common
    from google.cloud.firestore_v1.types import document
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.transforms import DELETE_FIELD
    from google.api_core.retry import Retry
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import write
    from google.protobuf import timestamp_pb2
    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.types import document
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.transaction import Transaction
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
    from google.api_core.retry import Retry
    from google.cloud.firestore_v1.async_client import AsyncClient



@pytest.mark.asyncio
async def test_asyncdocumentreference_set_w_retry_timeout():

    retry = Retry(predicate=object())
    timeout = 123.0
    await _set_helper(retry=retry, timeout=timeout)


@pytest.mark.asyncio
async def test_asyncdocumentreference_set_merge():
    await _set_helper(merge=True)


def _write_pb_for_update(document_path, update_values, field_paths):

    return write.Write(
        update=document.Document(
            name=document_path, fields=_helpers.encode_dict(update_values)
        ),
        update_mask=common.DocumentMask(field_paths=field_paths),
        current_document=common.Precondition(exists=True),
    )


@pytest.mark.asyncio
async def _update_helper(retry=None, timeout=None, **option_kwargs):

    # Create a minimal fake GAPIC with a dummy response.

    firestore_api = AsyncMock(spec=["commit"])