parent
f3091c6424
commit
ff0a292548
2 changed files with 14 additions and 0 deletions
|
@ -13,6 +13,7 @@ from operator import itemgetter
|
|||
from stringscore import liquidmetal
|
||||
from util.names import parse_robot_username
|
||||
|
||||
import anunidecode # Don't listen to pylint's lies. This import is required.
|
||||
import math
|
||||
|
||||
@resource('/v1/entities/<prefix>')
|
||||
|
@ -27,6 +28,11 @@ class EntitySearch(ApiResource):
|
|||
@nickname('getMatchingEntities')
|
||||
def get(self, prefix, parsed_args):
|
||||
""" Get a list of entities that match the specified prefix. """
|
||||
|
||||
# Ensure we don't have any unicode characters in the search, as it breaks the search. Nothing
|
||||
# being searched can have unicode in it anyway, so this is a safe operation.
|
||||
prefix = prefix.encode('unidecode', 'ignore').replace(' ', '').lower()
|
||||
|
||||
teams = []
|
||||
org_data = []
|
||||
|
||||
|
|
|
@ -738,6 +738,14 @@ class TestConductSearch(ApiTestCase):
|
|||
|
||||
|
||||
class TestGetMatchingEntities(ApiTestCase):
|
||||
def test_unicode_search(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
json = self.getJsonResponse(EntitySearch,
|
||||
params=dict(prefix='北京市', namespace=ORGANIZATION,
|
||||
includeTeams='true'))
|
||||
self.assertEquals(0, len(json['results']))
|
||||
|
||||
def test_notinorg(self):
|
||||
self.login(NO_ACCESS_USER)
|
||||
|
||||
|
|
Reference in a new issue