18 lines
489 B
Python
18 lines
489 B
Python
|
|
import pytest
|
||
|
|
|
||
|
|
from app_new.core.models.user import User
|
||
|
|
|
||
|
|
|
||
|
|
def test_user_password_hashing():
|
||
|
|
user = User(username='unit', password_hash='')
|
||
|
|
user.set_password('monsecret')
|
||
|
|
assert user.check_password('monsecret')
|
||
|
|
assert not user.check_password('mauvais')
|
||
|
|
|
||
|
|
|
||
|
|
def test_user_admin_role():
|
||
|
|
user = User(username='admin', role='admin', password_hash='')
|
||
|
|
assert user.is_admin()
|
||
|
|
user2 = User(username='user', role='user', password_hash='')
|
||
|
|
assert not user2.is_admin()
|