Fix entity search API to not IndexError
This commit is contained in:
parent
a3c540efcb
commit
3fd92aef35
2 changed files with 16 additions and 1 deletions
|
@ -514,7 +514,7 @@ def get_matching_users(username_prefix, robot_namespace=None, organization=None,
|
||||||
direct_user_query = (direct_user_query | (robot_search & (User.robot == True)))
|
direct_user_query = (direct_user_query | (robot_search & (User.robot == True)))
|
||||||
|
|
||||||
query = (User
|
query = (User
|
||||||
.select(User.username, User.email, User.robot)
|
.select(User.id, User.username, User.email, User.robot)
|
||||||
.group_by(User.username, User.email, User.robot)
|
.group_by(User.username, User.email, User.robot)
|
||||||
.where(direct_user_query))
|
.where(direct_user_query))
|
||||||
|
|
||||||
|
|
|
@ -776,6 +776,21 @@ class TestConductSearch(ApiTestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestGetMatchingEntities(ApiTestCase):
|
class TestGetMatchingEntities(ApiTestCase):
|
||||||
|
def test_simple_lookup(self):
|
||||||
|
self.login(ADMIN_ACCESS_USER)
|
||||||
|
|
||||||
|
json = self.getJsonResponse(EntitySearch,
|
||||||
|
params=dict(prefix=ADMIN_ACCESS_USER, namespace=ORGANIZATION,
|
||||||
|
includeTeams='true'))
|
||||||
|
self.assertEquals(1, len(json['results']))
|
||||||
|
|
||||||
|
def test_simple_lookup_noorg(self):
|
||||||
|
self.login(ADMIN_ACCESS_USER)
|
||||||
|
|
||||||
|
json = self.getJsonResponse(EntitySearch,
|
||||||
|
params=dict(prefix=ADMIN_ACCESS_USER))
|
||||||
|
self.assertEquals(1, len(json['results']))
|
||||||
|
|
||||||
def test_unicode_search(self):
|
def test_unicode_search(self):
|
||||||
self.login(ADMIN_ACCESS_USER)
|
self.login(ADMIN_ACCESS_USER)
|
||||||
|
|
||||||
|
|
Reference in a new issue