Fix entity search API to not IndexError

This commit is contained in:
Joseph Schorr 2016-11-02 16:22:35 -04:00
parent a3c540efcb
commit 3fd92aef35
2 changed files with 16 additions and 1 deletions

View file

@ -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)))
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)
.where(direct_user_query))

View file

@ -776,6 +776,21 @@ class TestConductSearch(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):
self.login(ADMIN_ACCESS_USER)