def test_handles_unicode(self): id = u("中文") self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))
def test_body_gets_encoded_into_bytes(self): t = Transport([{}], connection_class=DummyConnection) t.perform_request('GET', '/', body=u('你好')) self.assertEquals(1, len(t.get_connection().calls)) self.assertEquals(('GET', '/', None, b'\xe4\xbd\xa0\xe5\xa5\xbd'), t.get_connection().calls[0][0])
def test_handles_utf_encoded_string(self): if not PY2: raise SkipTest('Only relevant for py2') id = u("中文").encode('utf-8') self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))
def test_unicode(self): self.mc_client.index("test_index", "test_type", {"answer": u("你好")}, id=u("你好")) self.assertEquals({"answer": u("你好")}, self.mc_client.get("test_index", doc_type="test_type", id=u("你好"))["_source"])
def test_strings_are_parsed_for_port(self): self.assertEquals( [{"host": "elasticsearch.org", "port": 42}, {"host": "user:[email protected]"}], _normalize_hosts(["elasticsearch.org:42", u("user:[email protected]")]) )