Browse Source

renamed models.users to model.account

master
Holger Frey 7 years ago
parent
commit
f2d33f50ba
  1. 2
      ordr2/models/__init__.py
  2. 0
      ordr2/models/account.py
  3. 2
      ordr2/security.py
  4. 2
      tests/__init__.py
  5. 2
      tests/_functional/__init__.py
  6. 21
      tests/models/account.py

2
ordr2/models/__init__.py

@ -11,7 +11,7 @@ import zope.sqlalchemy @@ -11,7 +11,7 @@ import zope.sqlalchemy
# import or define all models here to ensure they are attached to the
# Base.metadata prior to any initialization routines
from .users import User, Role # flake8: noqa
from .account import User, Role # flake8: noqa
# run configure_mappers after defining all of the models to ensure
# all relationships can be setup

0
ordr2/models/users.py → ordr2/models/account.py

2
ordr2/security.py

@ -4,7 +4,7 @@ from pyramid.authentication import AuthTktAuthenticationPolicy @@ -4,7 +4,7 @@ from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.security import Authenticated, Everyone
from ordr2.models.users import User, passlib_context
from ordr2.models.account import User, passlib_context
class AuthenticationPolicy(AuthTktAuthenticationPolicy):

2
tests/__init__.py

@ -43,7 +43,7 @@ def app_config(): @@ -43,7 +43,7 @@ def app_config():
with testing.testConfig(settings=APP_SETTINGS) as config:
#config.include('pyramid_mailer.testing')
from ordr2.models.users import passlib_context
from ordr2.models.account import passlib_context
passlib_context.update(schemes=['argon2'])
yield config

2
tests/_functional/__init__.py

@ -44,7 +44,7 @@ class CustomTestApp(webtest.TestApp): @@ -44,7 +44,7 @@ class CustomTestApp(webtest.TestApp):
def testapp():
''' fixture for using webtest '''
from ordr2.models.meta import Base
from ordr2.models import get_tm_session, Role
from ordr2.models import get_tm_session
from ordr2 import main
app = main({}, **WEBTEST_SETTINGS)

21
tests/models/users.py → tests/models/account.py

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
''' Test package for ordr2.models.users '''
''' Test package for ordr2.models.account '''
import pytest
@ -7,7 +7,7 @@ import pytest @@ -7,7 +7,7 @@ import pytest
def test_role_principals():
''' test Role.principal, a caluclated property '''
from ordr2.models.users import Role
from ordr2.models.account import Role
assert Role.UNVALIDATED.principal == 'role:unvalidated'
assert Role.NEW.principal == 'role:new'
@ -19,7 +19,7 @@ def test_role_principals(): @@ -19,7 +19,7 @@ def test_role_principals():
def test_role_str():
''' test the string representation of roles '''
from ordr2.models.users import Role
from ordr2.models.account import Role
assert str(Role.UNVALIDATED) == 'Unvalidated'
assert str(Role.NEW) == 'New'
@ -33,7 +33,7 @@ def test_role_str(): @@ -33,7 +33,7 @@ def test_role_str():
def test_user_principal():
''' test the user principal calculated property '''
from ordr2.models.users import User
from ordr2.models.account import User
user = User(id=3)
@ -52,7 +52,7 @@ def test_user_principal(): @@ -52,7 +52,7 @@ def test_user_principal():
)
def test_user_role_principals(role_name, principals):
''' test the user's role principals calculated property '''
from ordr2.models.users import User, Role
from ordr2.models.account import User, Role
role = Role[role_name]
user = User(role=role)
@ -72,7 +72,7 @@ def test_user_role_principals(role_name, principals): @@ -72,7 +72,7 @@ def test_user_role_principals(role_name, principals):
)
def test_user_is_active(role_name, is_active):
''' test if is_active returns correct value based on the user's role '''
from ordr2.models.users import User, Role
from ordr2.models.account import User, Role
role = Role[role_name]
user = User(role=role)
@ -82,7 +82,7 @@ def test_user_is_active(role_name, is_active): @@ -82,7 +82,7 @@ def test_user_is_active(role_name, is_active):
def test_user_set_password():
''' test password hash generation '''
from ordr2.models.users import User, passlib_context
from ordr2.models.account import User, passlib_context
passlib_context.update(schemes=['argon2', 'bcrypt'])
user = User(password_hash=None)
@ -101,7 +101,7 @@ def test_user_set_password(): @@ -101,7 +101,7 @@ def test_user_set_password():
)
def test_user_check_password_ok(password):
''' test password check '''
from ordr2.models.users import User, passlib_context
from ordr2.models.account import User, passlib_context
passlib_context.update(schemes=['argon2', 'bcrypt'], deprecated='auto')
user = User(password_hash=None)
@ -112,7 +112,7 @@ def test_user_check_password_ok(password): @@ -112,7 +112,7 @@ def test_user_check_password_ok(password):
def test_user_check_password_deprecated_hash():
''' test password check updates deprecated hash with new algorithm '''
from ordr2.models.users import User
from ordr2.models.account import User
from ordr2.security import passlib_context
passlib_context.update(schemes=['argon2', 'bcrypt'], deprecated='auto')
@ -125,10 +125,9 @@ def test_user_check_password_deprecated_hash(): @@ -125,10 +125,9 @@ def test_user_check_password_deprecated_hash():
assert user.password_hash.startswith('$argon2')
def test_user_string_representation():
''' test the string representation of the user '''
from ordr2.models.users import User, Role
from ordr2.models.account import User, Role
user = User(username='FooBar')