File: test_utils.py

package info (click to toggle)
python-elasticsearch 1.4.0-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 636 kB
  • sloc: python: 3,209; makefile: 155
file content (19 lines) | stat: -rw-r--r-- 651 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from elasticsearch.client.utils import _make_path
from elasticsearch.compat import PY2

from ..test_cases import TestCase, SkipTest

class TestMakePath(TestCase):
    def test_handles_unicode(self):
        id = "中文"
        self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))

    def test_handles_utf_encoded_string(self):
        if not PY2:
            raise SkipTest('Only relevant for py2')
        id = "中文".encode('utf-8')
        self.assertEquals('/some-index/type/%E4%B8%AD%E6%96%87', _make_path('some-index', 'type', id))