Example #1
0
def test_get_matching_users(initialized_db):
  # Exact match.
  for user in User.select().where(User.organization == False, User.robot == False):
    assert list(get_matching_users(user.username))[0].username == user.username

  # Prefix matching.
  for user in User.select().where(User.organization == False, User.robot == False):
    assert user.username in [r.username for r in get_matching_users(user.username[:2])]
Example #2
0
def test_get_matching_users_with_same_prefix(initialized_db):
  # Create a bunch of users with the same prefix.
  for index in range(0, 20):
    create_user_noverify('foo%s' % index, '*****@*****.**' % index, email_required=False)

  # For each user, ensure that lookup of the exact name is found first.
  for index in range(0, 20):
    username = '******' % index
    assert list(get_matching_users(username))[0].username == username

  # Prefix matching.
  found = list(get_matching_users('foo', limit=50))
  assert len(found) == 20