Add a check for a string value in Elasticsearch 'URLS' setting

pull/6451/head
Sævar Öfjörð Magnússon 2020-10-06 14:01:58 +00:00 zatwierdzone przez GitHub
rodzic f2dfff8061
commit bcf1fab77f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 23 dodań i 0 usunięć

Wyświetl plik

@ -1070,6 +1070,10 @@ class Elasticsearch2SearchBackend(BaseSearchBackend):
if self.hosts is None:
self.hosts = []
# if es_urls is not a list, convert it to a list
if isinstance(es_urls, str):
es_urls = [es_urls]
for url in es_urls:
parsed_url = urlparse(url)

Wyświetl plik

@ -833,6 +833,25 @@ class TestBackendConfiguration(TestCase):
timeout=10
)
def test_urls_as_string_works(self, Elasticsearch):
Elasticsearch2SearchBackend(params={
'URLS': 'http://localhost:9200'
})
Elasticsearch.assert_called_with(
hosts=[
{
'host': 'localhost',
'port': 9200,
'url_prefix': '',
'use_ssl': False,
'verify_certs': False,
'http_auth': None,
}
],
timeout=10
)
class TestGetModelRoot(TestCase):
def test_root_model(self):