Commit 48787f16 by Tim Babych Committed by Oleg Marshev

unicode-aware urlencode

parent 945a11fd
# -*- coding: utf-8 -*-
import jwt import jwt
import urllib
from calendar import timegm from calendar import timegm
from datetime import datetime, timedelta from datetime import datetime, timedelta
from mock import patch from mock import patch
...@@ -7,6 +7,7 @@ import unittest ...@@ -7,6 +7,7 @@ import unittest
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from django.http import QueryDict
from rest_framework import status from rest_framework import status
from rest_framework.test import APITestCase from rest_framework.test import APITestCase
...@@ -110,8 +111,9 @@ class BaseAnnotationViewTests(APITestCase): ...@@ -110,8 +111,9 @@ class BaseAnnotationViewTests(APITestCase):
""" """
Helper for search method. All keyword parameters are passed in GET Helper for search method. All keyword parameters are passed in GET
""" """
kwargs.update({"user": TEST_USER}) q = QueryDict("user=" + TEST_USER, mutable=True)
url = reverse('api:v1:annotations_search') + '?{}'.format(urllib.urlencode(kwargs)) q.update(kwargs)
url = reverse('api:v1:annotations_search') + '?{}'.format(q.urlencode())
result = self.client.get(url) result = self.client.get(url)
return result.data return result.data
...@@ -329,6 +331,18 @@ class AnnotationViewTests(BaseAnnotationViewTests): ...@@ -329,6 +331,18 @@ class AnnotationViewTests(BaseAnnotationViewTests):
self.assertEqual(results['rows'][1]['text'], 'Second note') self.assertEqual(results['rows'][1]['text'], 'Second note')
self.assertEqual(results['rows'][2]['text'], 'First one') self.assertEqual(results['rows'][2]['text'], 'First one')
# def test_search_unicode(self):
# """
# Tests searching of unicode strings.
# """
# self._create_annotation(text=u'Веселих свят')
# results = self._get_search_results(text=u"веселих".encode('utf-8'))
# self.assertEqual(results['total'], 1)
# results = self._get_search_results(text=u"свят")
# self.assertEqual(results['total'], 1)
def test_read_all_no_annotations(self): def test_read_all_no_annotations(self):
""" """
Tests list all annotations endpoint when no annotations are present in elasticsearch. Tests list all annotations endpoint when no annotations are present in elasticsearch.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment