##// END OF EJS Templates
old style: fix text areas in fork dialog...
old style: fix text areas in fork dialog There's no textarea-repo style, so the entry box isn't properly aligned.

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4155:cee56368 rhodecode-2.2.5-gpl
Show More
test_users.py
130 lines | 4.4 KiB | text/x-python | PythonLexer
orginized test module...
r2527 from rhodecode.tests import *
Mads Kiilerich
further cleanup of UsersGroup...
r3417 from rhodecode.model.db import User, UserGroup, UserGroupMember, UserEmailMap,\
orginized test module...
r2527 Permission
from rhodecode.model.user import UserModel
from rhodecode.model.meta import Session
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 from rhodecode.model.user_group import UserGroupModel
- Manage User’s Groups: create, delete, rename, add/remove users inside....
r3714 from rhodecode.tests.fixture import Fixture
fixture = Fixture()
orginized test module...
r2527
created basic TestClass for tests that does...
r3829 class TestUser(BaseTestCase):
orginized test module...
r2527 def __init__(self, methodName='runTest'):
Session.remove()
super(TestUser, self).__init__(methodName=methodName)
more usage of fixture tools...
r3647 def tearDown(self):
Session.remove()
orginized test module...
r2527 def test_create_and_remove(self):
usr = UserModel().create_or_update(username=u'test_user',
password=u'qweqwe',
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 email=u'u232@rhodecode.org',
firstname=u'u1', lastname=u'u1')
orginized test module...
r2527 Session().commit()
self.assertEqual(User.get_by_username(u'test_user'), usr)
fixed tests and missing replacements from 5f1850e4712a
r3415 # make user group
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 user_group = fixture.create_user_group('some_example_group')
orginized test module...
r2527 Session().commit()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 UserGroupModel().add_user_to_group(user_group, usr)
orginized test module...
r2527 Session().commit()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 self.assertEqual(UserGroup.get(user_group.users_group_id), user_group)
Mads Kiilerich
further cleanup of UsersGroup...
r3417 self.assertEqual(UserGroupMember.query().count(), 1)
orginized test module...
r2527 UserModel().delete(usr.user_id)
Session().commit()
Mads Kiilerich
further cleanup of UsersGroup...
r3417 self.assertEqual(UserGroupMember.query().all(), [])
orginized test module...
r2527
def test_additonal_email_as_main(self):
usr = UserModel().create_or_update(username=u'test_user',
password=u'qweqwe',
email=u'main_email@rhodecode.org',
firstname=u'u1', lastname=u'u1')
Session().commit()
def do():
m = UserEmailMap()
m.email = u'main_email@rhodecode.org'
m.user = usr
Session().add(m)
Session().commit()
self.assertRaises(AttributeError, do)
UserModel().delete(usr.user_id)
Session().commit()
def test_extra_email_map(self):
usr = UserModel().create_or_update(username=u'test_user',
password=u'qweqwe',
email=u'main_email@rhodecode.org',
firstname=u'u1', lastname=u'u1')
Session().commit()
m = UserEmailMap()
m.email = u'main_email2@rhodecode.org'
m.user = usr
Session().add(m)
Session().commit()
u = User.get_by_email(email='main_email@rhodecode.org')
self.assertEqual(usr.user_id, u.user_id)
self.assertEqual(usr.username, u.username)
u = User.get_by_email(email='main_email2@rhodecode.org')
self.assertEqual(usr.user_id, u.user_id)
self.assertEqual(usr.username, u.username)
u = User.get_by_email(email='main_email3@rhodecode.org')
self.assertEqual(None, u)
UserModel().delete(usr.user_id)
Session().commit()
created basic TestClass for tests that does...
r3829 class TestUsers(BaseTestCase):
orginized test module...
r2527
def __init__(self, methodName='runTest'):
super(TestUsers, self).__init__(methodName=methodName)
def setUp(self):
self.u1 = UserModel().create_or_update(username=u'u1',
password=u'qweqwe',
email=u'u1@rhodecode.org',
firstname=u'u1', lastname=u'u1')
def tearDown(self):
perm = Permission.query().all()
for p in perm:
UserModel().revoke_perm(self.u1, p)
UserModel().delete(self.u1)
Session().commit()
more usage of fixture tools...
r3647 Session.remove()
orginized test module...
r2527
def test_add_perm(self):
perm = Permission.query().all()[0]
UserModel().grant_perm(self.u1, perm)
Session().commit()
self.assertEqual(UserModel().has_perm(self.u1, perm), True)
def test_has_perm(self):
perm = Permission.query().all()
for p in perm:
has_p = UserModel().has_perm(self.u1, p)
self.assertEqual(False, has_p)
def test_revoke_perm(self):
perm = Permission.query().all()[0]
UserModel().grant_perm(self.u1, perm)
Session().commit()
self.assertEqual(UserModel().has_perm(self.u1, perm), True)
#revoke
UserModel().revoke_perm(self.u1, perm)
Session().commit()
self.assertEqual(UserModel().has_perm(self.u1, perm), False)