Changeset View
Changeset View
Standalone View
Standalone View
swh/search/tests/test_elasticsearch.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import unittest | import unittest | ||||
import pytest | import pytest | ||||
from swh.search import get_search | |||||
from .test_search import CommonSearchTest | from .test_search import CommonSearchTest | ||||
class BaseElasticsearchTest(unittest.TestCase): | class BaseElasticsearchTest(unittest.TestCase): | ||||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | ||||
def _instantiate_search(self, elasticsearch_host): | def _instantiate_search(self, swh_search, elasticsearch_host): | ||||
self._elasticsearch_host = elasticsearch_host | self._elasticsearch_host = elasticsearch_host | ||||
self.search = get_search("elasticsearch", {"hosts": [elasticsearch_host],}) | self.search = swh_search | ||||
def setUp(self): | |||||
self.reset() | |||||
def reset(self): | def reset(self): | ||||
self.search.deinitialize() | self.search.deinitialize() | ||||
self.search.initialize() | self.search.initialize() | ||||
class TestElasticsearchSearch(CommonSearchTest, BaseElasticsearchTest): | class TestElasticsearchSearch(CommonSearchTest, BaseElasticsearchTest): | ||||
pass | pass |