Add search tests

This commit is contained in:
Joseph Schorr 2015-04-07 14:05:12 -04:00
parent 1b56567268
commit 40a6892a49
3 changed files with 92 additions and 9 deletions

View file

@ -681,8 +681,12 @@ def get_user_or_org_by_customer_id(customer_id):
def get_matching_user_entities(entity_prefix, user):
matching_user_orgs = ((User.username ** (entity_prefix + '%')) & (User.robot == False))
matching_robots = ((User.username ** (user.username + '+%' + entity_prefix + '%')) &
(User.robot == True))
if user is not None:
matching_robots = ((User.username ** (user.username + '+%' + entity_prefix + '%')) &
(User.robot == True))
else:
matching_robots = False
query = (User.select()
.where(matching_user_orgs | matching_robots)