Add common_login test
This commit is contained in:
parent
41ac9019c6
commit
7736de24fe
2 changed files with 26 additions and 1 deletions
|
@ -48,7 +48,7 @@ def common_login(db_user, permanent_session=True):
|
|||
|
||||
return True
|
||||
else:
|
||||
logger.debug('User could not be logged in, inactive?.')
|
||||
logger.debug('User could not be logged in, inactive?')
|
||||
return False
|
||||
|
||||
|
||||
|
|
25
endpoints/test/test_common.py
Normal file
25
endpoints/test/test_common.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
|
||||
from data import model
|
||||
from endpoints.common import common_login
|
||||
|
||||
from test.fixtures import *
|
||||
|
||||
@pytest.mark.parametrize('username, expect_success', [
|
||||
# Valid users.
|
||||
('devtable', True),
|
||||
('public', True),
|
||||
|
||||
# Org.
|
||||
('buynlarge', False),
|
||||
|
||||
# Robot.
|
||||
('devtable+dtrobot', False),
|
||||
|
||||
# Unverified user.
|
||||
('unverified', False),
|
||||
])
|
||||
def test_common_login(username, expect_success, app):
|
||||
db_user = model.user.get_namespace_user(username)
|
||||
with app.app_context():
|
||||
assert common_login(db_user) == expect_success
|
Reference in a new issue