# Path: virtool/db/utils.py
# @asynccontextmanager
# async def buffered_bulk_writer(collection, batch_size=100):
#     """
#     A context manager for bulk writing to MongoDB.
# 
#     Returns a :class:``BufferedBulkWriter`` object. Automatically flushes the buffer
#     when the context manager exits.
# 
#     :param collection: the MongoDB collection to write against
#     :param batch_size: the number of requests to be sent in each bulk operation
# 
#     """
#     writer = BufferedBulkWriter(collection, batch_size)
# 
#     try:
#         yield writer
#     finally:
#         await writer.flush()


import pytest
import virtool.db
import virtool.db.utils
from virtool.db.utils import buffered_bulk_writer


class TestApplyProjection:
    @pytest.mark.parametrize(
        "projection,expected",
        [
            (["_id", "name"], {"_id": "foo", "name": "bar"}),

# Path: virtool/db/utils.py
# @asynccontextmanager
# async def buffered_bulk_writer(collection, batch_size=100):
#     """
#     A context manager for bulk writing to MongoDB.
# 
#     Returns a :class:``BufferedBulkWriter`` object. Automatically flushes the buffer
#     when the context manager exits.
# 
#     :param collection: the MongoDB collection to write against
#     :param batch_size: the number of requests to be sent in each bulk operation
# 
#     """
#     writer = BufferedBulkWriter(collection, batch_size)
# 
#     try:
#         yield writer
#     finally:
#         await writer.flush()


# Path: tests/db/test_utils.py
import pytest
import virtool.db
import virtool.db.utils
from virtool.db.utils import buffered_bulk_writer



class TestApplyProjection:
    @pytest.mark.parametrize(
        "projection,expected",
        [
            (["_id", "name"], {"_id": "foo", "name": "bar"}),

            (["name"], {"_id": "foo", "name": "bar"}),