# 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 mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncMock
    from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import write
    from google.api_core.retry import Retry
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1.client import Client
    timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798)
    commit_response = firestore.CommitResponse(
        write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp,
    )
    firestore_api.commit.return_value = commit_response
    kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout)

    # Attach the fake GAPIC to a real client.
    client = _make_client("grand")
    client._firestore_api_internal = firestore_api

    # Actually make a batch with some mutations and call commit().
    batch = _make_async_write_batch(client)
    document1 = client.document("a", "b")
    batch.create(document1, {"ten": 10, "buck": "ets"})
    document2 = client.document("c", "d", "e", "f")
    batch.delete(document2)
    write_pbs = batch._write_pbs[::]

    write_results = await batch.commit(**kwargs)

    assert write_results == list(commit_response.write_results)
    assert batch.write_results == write_results
    assert batch.commit_time.timestamp_pb() == timestamp
    # Make sure batch has no more "changes".
    assert batch._write_pbs == []

    # Verify the mocks.
    firestore_api.commit.assert_called_once_with(
        request={

# 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_batch.py
import mock
import pytest
    import google.auth.credentials
from tests.unit.v1.test__helpers import AsyncMock
    from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1 import _helpers
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import write
    from google.api_core.retry import Retry
    from google.protobuf import timestamp_pb2
    from google.cloud.firestore_v1.types import firestore
    from google.cloud.firestore_v1.types import write
    from google.cloud.firestore_v1.client import Client

    timestamp = timestamp_pb2.Timestamp(seconds=1234567, nanos=123456798)
    commit_response = firestore.CommitResponse(
        write_results=[write.WriteResult(), write.WriteResult()], commit_time=timestamp,
    )
    firestore_api.commit.return_value = commit_response
    kwargs = _helpers.make_retry_timeout_kwargs(retry, timeout)

    # Attach the fake GAPIC to a real client.
    client = _make_client("grand")
    client._firestore_api_internal = firestore_api

    # Actually make a batch with some mutations and call commit().
    batch = _make_async_write_batch(client)
    document1 = client.document("a", "b")
    batch.create(document1, {"ten": 10, "buck": "ets"})
    document2 = client.document("c", "d", "e", "f")
    batch.delete(document2)
    write_pbs = batch._write_pbs[::]

    write_results = await batch.commit(**kwargs)

    assert write_results == list(commit_response.write_results)
    assert batch.write_results == write_results
    assert batch.commit_time.timestamp_pb() == timestamp
    # Make sure batch has no more "changes".
    assert batch._write_pbs == []

    # Verify the mocks.
    firestore_api.commit.assert_called_once_with(
        request={

            "database": client._database_string,