20 lines
683 B
Python
20 lines
683 B
Python
import pytest
|
|
from web.db import db_init, create_or_update_user, verify_user_credentials, get_users
|
|
from web.utils import initialize_users_from_settings
|
|
|
|
|
|
def test_initialize_users_from_settings():
|
|
db_init()
|
|
n = initialize_users_from_settings()
|
|
assert n >= 1 # should at least add 'anonymous'
|
|
users = get_users()
|
|
assert any(u['username'] == 'anonymous' for u in users)
|
|
|
|
|
|
def test_create_and_auth_user():
|
|
db_init()
|
|
create_or_update_user('testuser', password='secret',
|
|
is_admin=True, is_active=True)
|
|
assert verify_user_credentials('testuser', 'secret') is True
|
|
assert verify_user_credentials('testuser', 'wrong') is False
|