# Path: tests_integ/asyncio/conftest.py
# def event_loop(request):
# async def es_client(event_loop, es_url):
# def es_cluster(es_client):
# async def es_index(es_cluster, es_client, index_name):
# async def cars(es_index, car_docs):
# async def all_cars(es_index, all_car_docs):


import pytest
from .conftest import Car

    cached_res = await sq.get_result()
    assert cached_res is res


@pytest.mark.asyncio
async def test_count(es_index, cars):
    assert await es_index.search_query().count() == 2
    assert await es_index.search_query(Car.name.match('Sally')).count() == 1


@pytest.mark.asyncio
async def test_exists(es_index, cars):
    assert await es_index.search_query().exists()
    assert await es_index.search_query(Car.name.match('Sally')).exists()
    assert not await es_index.search_query(Car.name.match('Buzz')).exists()


@pytest.mark.asyncio
async def test_iter(es_index, cars):
    sq = (
        es_index.search_query(Car.name.match('Sally'))
        .limit(1)
    )

    for doc in await sq:
        assert isinstance(doc, Car)
        assert doc._id == '2'

    for doc in await sq:

# Path: tests_integ/asyncio/conftest.py
# def event_loop(request):
# async def es_client(event_loop, es_url):
# def es_cluster(es_client):
# async def es_index(es_cluster, es_client, index_name):
# async def cars(es_index, car_docs):
# async def all_cars(es_index, all_car_docs):


# Path: tests_integ/asyncio/test_search.py
import pytest
from .conftest import Car


    cached_res = await sq.get_result()
    assert cached_res is res


@pytest.mark.asyncio
async def test_count(es_index, cars):
    assert await es_index.search_query().count() == 2
    assert await es_index.search_query(Car.name.match('Sally')).count() == 1


@pytest.mark.asyncio
async def test_exists(es_index, cars):
    assert await es_index.search_query().exists()
    assert await es_index.search_query(Car.name.match('Sally')).exists()
    assert not await es_index.search_query(Car.name.match('Buzz')).exists()


@pytest.mark.asyncio
async def test_iter(es_index, cars):
    sq = (
        es_index.search_query(Car.name.match('Sally'))
        .limit(1)
    )

    for doc in await sq:
        assert isinstance(doc, Car)
        assert doc._id == '2'

    for doc in await sq:

        assert isinstance(doc, Car)