# Path: api/tests/utils.py
# class APITestCase(TestCase):
#     @run_sync
#     async def tearDown(self):
#         await clear_index()
#         await refresh_index()
# 
#     def get(self, path, *args, **kwargs):
#         return requests.get(
#             urljoin('http://127.0.0.1:8000', path), *args, **kwargs)
# 
# async def refresh_index():
#     await elastic.indices.refresh(ELASTICSEARCH_INDEX)
# 
# def run_sync(coro):
#     @wraps(coro)
#     def wrapper(*args, **kwargs):
#         future = coro(*args, **kwargs)
#         loop = asyncio.get_event_loop()
#         return loop.run_until_complete(future)
#     return wrapper
# 
# Path: api/tests/factories.py
# class Place(Factory):
#     doc_type = 'place'
# 
# class Event(Factory):
#     doc_type = 'event'


from ..utils import APITestCase, refresh_index, run_sync
from ..factories import Place, Event


class SearchTestCase(APITestCase):
    @run_sync
    async def test_finds_items_by_name(self):
        await Place.create(name="Ненаходимое место")
        matching_items = {

# Path: api/tests/utils.py
# class APITestCase(TestCase):
#     @run_sync
#     async def tearDown(self):
#         await clear_index()
#         await refresh_index()
# 
#     def get(self, path, *args, **kwargs):
#         return requests.get(
#             urljoin('http://127.0.0.1:8000', path), *args, **kwargs)
# 
# async def refresh_index():
#     await elastic.indices.refresh(ELASTICSEARCH_INDEX)
# 
# def run_sync(coro):
#     @wraps(coro)
#     def wrapper(*args, **kwargs):
#         future = coro(*args, **kwargs)
#         loop = asyncio.get_event_loop()
#         return loop.run_until_complete(future)
#     return wrapper
# 
# Path: api/tests/factories.py
# class Place(Factory):
#     doc_type = 'place'
# 
# class Event(Factory):
#     doc_type = 'event'


# Path: api/tests/v1/test_search.py
from ..utils import APITestCase, refresh_index, run_sync
from ..factories import Place, Event



class SearchTestCase(APITestCase):
    @run_sync
    async def test_finds_items_by_name(self):
        await Place.create(name="Ненаходимое место")
        matching_items = {

            ('place', await Place.create(name="Тестовое место")),