Support RFC-1738 URLs

Fixes #149
This commit is contained in:
Rémy HUBSCHER
2014-11-14 15:42:37 +01:00
committed by Honza Král
parent 03a817690d
commit 923ee018cf
3 changed files with 29 additions and 15 deletions
+9 -2
View File
@@ -13,12 +13,19 @@ class TestNormalizeHosts(TestCase):
def test_strings_are_used_as_hostnames(self):
self.assertEquals([{"host": "elasticsearch.org"}], _normalize_hosts(["elasticsearch.org"]))
def test_strings_are_parsed_for_port(self):
def test_strings_are_parsed_for_port_and_user(self):
self.assertEquals(
[{"host": "elasticsearch.org", "port": 42}, {"host": "user:secret@elasticsearch.com"}],
[{"host": "elasticsearch.org", "port": 42}, {"host": "elasticsearch.com", "http_auth": "user:secret"}],
_normalize_hosts(["elasticsearch.org:42", "user:[email protected]"])
)
def test_strings_are_parsed_for_scheme(self):
self.assertEquals(
[{"host": "elasticsearch.org", "port": 42, "use_ssl": True},
{"host": "elasticsearch.com", "http_auth": "user:secret", "use_ssl": True, "port": 443}],
_normalize_hosts(["https://elasticsearch.org:42", "https://user:[email protected]"])
)
def test_dicts_are_left_unchanged(self):
self.assertEquals([{"host": "local", "extra": 123}], _normalize_hosts([{"host": "local", "extra": 123}]))