Files
@ e13a747e9c6a
Branch filter:
Location: kallithea/rhodecode/tests/models/test_users.py
e13a747e9c6a
4.4 KiB
text/x-python
Migrate to jQuery 1.10.2 from 1.10.1.
Include the minified version of jQuery 1.10.2 instead of 1.10.1. The 1.10.2
files were download via these commands:
$ wget -N http://code.jquery.com/jquery-1.10.2.min.js
$ wget -N http://code.jquery.com/jquery-1.10.2.min.map
Meanwhile, since the Javascript code is covered by GPLv3, we should always
provide an up-to-date version of the source code. I have included it
here by creating the directory jquery-src. I extracted the correct version
of the source with the following commands:
$ git clone git://github.com/jquery/jquery.git
$ git checkout 1.10.2
which is what the jQuery website instructs to do: http://jquery.com/download/
This repository is mirrorred at https://kallithea-scm.org/repos/mirror/jquery/ .
Include the minified version of jQuery 1.10.2 instead of 1.10.1. The 1.10.2
files were download via these commands:
$ wget -N http://code.jquery.com/jquery-1.10.2.min.js
$ wget -N http://code.jquery.com/jquery-1.10.2.min.map
Meanwhile, since the Javascript code is covered by GPLv3, we should always
provide an up-to-date version of the source code. I have included it
here by creating the directory jquery-src. I extracted the correct version
of the source with the following commands:
$ git clone git://github.com/jquery/jquery.git
$ git checkout 1.10.2
which is what the jQuery website instructs to do: http://jquery.com/download/
This repository is mirrorred at https://kallithea-scm.org/repos/mirror/jquery/ .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | from rhodecode.tests import *
from rhodecode.model.db import User, UserGroup, UserGroupMember, UserEmailMap,\
Permission
from rhodecode.model.user import UserModel
from rhodecode.model.meta import Session
from rhodecode.model.user_group import UserGroupModel
from rhodecode.tests.fixture import Fixture
fixture = Fixture()
class TestUser(BaseTestCase):
def __init__(self, methodName='runTest'):
Session.remove()
super(TestUser, self).__init__(methodName=methodName)
def tearDown(self):
Session.remove()
def test_create_and_remove(self):
usr = UserModel().create_or_update(username=u'test_user',
password=u'qweqwe',
email=u'u232@rhodecode.org',
firstname=u'u1', lastname=u'u1')
Session().commit()
self.assertEqual(User.get_by_username(u'test_user'), usr)
# make user group
user_group = fixture.create_user_group('some_example_group')
Session().commit()
UserGroupModel().add_user_to_group(user_group, usr)
Session().commit()
self.assertEqual(UserGroup.get(user_group.users_group_id), user_group)
self.assertEqual(UserGroupMember.query().count(), 1)
UserModel().delete(usr.user_id)
Session().commit()
self.assertEqual(UserGroupMember.query().all(), [])
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()
class TestUsers(BaseTestCase):
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()
Session.remove()
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)
|