# 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
    client = _make_client()
    client._firestore_api_internal = firestore_api
    batch = _make_async_write_batch(client)
    document1 = client.document("a", "b")
    document2 = client.document("c", "d", "e", "f")

    async with batch as ctx_mgr:
        assert ctx_mgr is batch
        ctx_mgr.create(document1, {"ten": 10, "buck": "ets"})
        ctx_mgr.delete(document2)
        write_pbs = batch._write_pbs[::]

    assert batch.write_results == list(commit_response.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,
            "writes": write_pbs,
            "transaction": None,
        },
        metadata=client._rpc_metadata,
    )


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

# 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

    client = _make_client()
    client._firestore_api_internal = firestore_api
    batch = _make_async_write_batch(client)
    document1 = client.document("a", "b")
    document2 = client.document("c", "d", "e", "f")

    async with batch as ctx_mgr:
        assert ctx_mgr is batch
        ctx_mgr.create(document1, {"ten": 10, "buck": "ets"})
        ctx_mgr.delete(document2)
        write_pbs = batch._write_pbs[::]

    assert batch.write_results == list(commit_response.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,
            "writes": write_pbs,
            "transaction": None,
        },
        metadata=client._rpc_metadata,
    )


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

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