From f2d33f50ba062dcb27075960c7779f28a4f548df Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 18 Oct 2017 16:19:41 +0200 Subject: [PATCH] renamed models.users to model.account --- ordr2/models/__init__.py | 2 +- ordr2/models/{users.py => account.py} | 0 ordr2/security.py | 2 +- tests/__init__.py | 2 +- tests/_functional/__init__.py | 2 +- tests/models/{users.py => account.py} | 21 ++++++++++----------- 6 files changed, 14 insertions(+), 15 deletions(-) rename ordr2/models/{users.py => account.py} (100%) rename tests/models/{users.py => account.py} (87%) diff --git a/ordr2/models/__init__.py b/ordr2/models/__init__.py index 1a507c8..357b7e5 100644 --- a/ordr2/models/__init__.py +++ b/ordr2/models/__init__.py @@ -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 diff --git a/ordr2/models/users.py b/ordr2/models/account.py similarity index 100% rename from ordr2/models/users.py rename to ordr2/models/account.py diff --git a/ordr2/security.py b/ordr2/security.py index 04e7bea..60336ca 100644 --- a/ordr2/security.py +++ b/ordr2/security.py @@ -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): diff --git a/tests/__init__.py b/tests/__init__.py index dba1d96..d3e20fb 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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 diff --git a/tests/_functional/__init__.py b/tests/_functional/__init__.py index c38ef86..3234789 100644 --- a/tests/_functional/__init__.py +++ b/tests/_functional/__init__.py @@ -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) diff --git a/tests/models/users.py b/tests/models/account.py similarity index 87% rename from tests/models/users.py rename to tests/models/account.py index ff67d53..1b0c778 100644 --- a/tests/models/users.py +++ b/tests/models/account.py @@ -1,4 +1,4 @@ -''' Test package for ordr2.models.users ''' +''' Test package for ordr2.models.account ''' 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(): 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(): 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(): ) 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): ) 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): 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(): ) 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): 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(): 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')