Merge pull request #2954 from coreos-inc/joseph.schorr/QS-102/user-api-filter
Add ability to filter users list to enabled users
This commit is contained in:
commit
13b738c43c
6 changed files with 60 additions and 40 deletions
|
@ -5,7 +5,7 @@ import pytest
|
|||
from mock import patch
|
||||
|
||||
from data.database import EmailConfirmation
|
||||
from data.model.user import create_user_noverify, validate_reset_code
|
||||
from data.model.user import create_user_noverify, validate_reset_code, get_active_users
|
||||
from util.timedeltastring import convert_to_timedelta
|
||||
from test.fixtures import *
|
||||
|
||||
|
@ -28,3 +28,13 @@ def test_validation_code(token_lifetime, time_since, initialized_db):
|
|||
result = validate_reset_code(confirmation.code)
|
||||
expect_success = convert_to_timedelta(token_lifetime) >= convert_to_timedelta(time_since)
|
||||
assert expect_success == (result is not None)
|
||||
|
||||
@pytest.mark.parametrize('disabled', [
|
||||
(True),
|
||||
(False),
|
||||
])
|
||||
def test_get_active_users(disabled, initialized_db):
|
||||
users = get_active_users(disabled=disabled)
|
||||
for user in users:
|
||||
if not disabled:
|
||||
assert user.enabled
|
||||
|
|
|
@ -750,8 +750,11 @@ def get_private_repo_count(username):
|
|||
.count())
|
||||
|
||||
|
||||
def get_active_users():
|
||||
return User.select().where(User.organization == False, User.robot == False)
|
||||
def get_active_users(disabled=True):
|
||||
query = User.select().where(User.organization == False, User.robot == False)
|
||||
if not disabled:
|
||||
query = query.where(User.enabled == True)
|
||||
return query
|
||||
|
||||
|
||||
def get_active_user_count():
|
||||
|
|
Reference in a new issue