##// END OF EJS Templates
unionrepo: update for Mercurial 2.6
unionrepo: update for Mercurial 2.6

File last commit:

r3889:b84c83b6 beta
r3976:42bca6fa default
Show More
test_admin_settings.py
265 lines | 11.0 KiB | text/x-python | PythonLexer
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 # -*- coding: utf-8 -*-
fixed test that broke admin email address
r754 from rhodecode.lib.auth import get_crypt_password, check_password
Fixed issue #501 error on setting set_as_fork to same repo...
r2629 from rhodecode.model.db import User, RhodeCodeSetting, Repository
renamed project to rhodecode
r547 from rhodecode.tests import *
Switched forms to new validators
r2467 from rhodecode.lib import helpers as h
Renamed name to firstname in forms...
r2544 from rhodecode.model.user import UserModel
Fixed issue #501 error on setting set_as_fork to same repo...
r2629 from rhodecode.model.scm import ScmModel
synced vcs with upstream...
r3797 from rhodecode.model.meta import Session
Switched forms to new validators
r2467
renamed project to rhodecode
r547
Refactor codes for scm model...
r691 class TestAdminSettingsController(TestController):
renamed project to rhodecode
r547
def test_index(self):
response = self.app.get(url('admin_settings'))
# Test response...
def test_index_as_xml(self):
response = self.app.get(url('formatted_admin_settings', format='xml'))
def test_create(self):
response = self.app.post(url('admin_settings'))
def test_new(self):
response = self.app.get(url('admin_new_setting'))
def test_new_as_xml(self):
response = self.app.get(url('formatted_admin_new_setting', format='xml'))
def test_update(self):
response = self.app.put(url('admin_setting', setting_id=1))
def test_update_browser_fakeout(self):
response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='put'))
def test_delete(self):
response = self.app.delete(url('admin_setting', setting_id=1))
def test_delete_browser_fakeout(self):
response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='delete'))
def test_show(self):
response = self.app.get(url('admin_setting', setting_id=1))
def test_show_as_xml(self):
response = self.app.get(url('formatted_admin_setting', setting_id=1, format='xml'))
def test_edit(self):
response = self.app.get(url('admin_edit_setting', setting_id=1))
def test_edit_as_xml(self):
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = self.app.get(url('formatted_admin_edit_setting',
setting_id=1, format='xml'))
renamed project to rhodecode
r547
updated tests for application settings
r893 def test_ga_code_active(self):
self.log_user()
old_title = 'RhodeCode'
old_realm = 'RhodeCode authentication'
new_ga_code = 'ga-test-123456789'
response = self.app.post(url('admin_setting', setting_id='global'),
params=dict(
_method='put',
rhodecode_title=old_title,
rhodecode_realm=old_realm,
rhodecode_ga_code=new_ga_code
))
Added CheckSessionFlash into init....
r1382 self.checkSessionFlash(response, 'Updated application settings')
refactoring of models names for repoGroup permissions
r1633 self.assertEqual(RhodeCodeSetting
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
updated tests for application settings
r893
response = response.follow()
Renamed name to firstname in forms...
r2544 response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code)
updated tests for application settings
r893
def test_ga_code_inactive(self):
self.log_user()
old_title = 'RhodeCode'
old_realm = 'RhodeCode authentication'
new_ga_code = ''
response = self.app.post(url('admin_setting', setting_id='global'),
params=dict(
_method='put',
rhodecode_title=old_title,
rhodecode_realm=old_realm,
rhodecode_ga_code=new_ga_code
))
unified flash msg tests
r3640 self.checkSessionFlash(response, 'Updated application settings')
refactoring of models names for repoGroup permissions
r1633 self.assertEqual(RhodeCodeSetting
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
updated tests for application settings
r893
response = response.follow()
Use only mustcontain for testing response body
r3646 response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])
updated tests for application settings
r893
def test_title_change(self):
self.log_user()
old_title = 'RhodeCode'
new_title = old_title + '_changed'
old_realm = 'RhodeCode authentication'
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
for new_title in ['Changed', 'Żółwik', old_title]:
response = self.app.post(url('admin_setting', setting_id='global'),
params=dict(
_method='put',
rhodecode_title=new_title,
rhodecode_realm=old_realm,
rhodecode_ga_code=''
))
updated tests for application settings
r893
Added CheckSessionFlash into init....
r1382 self.checkSessionFlash(response, 'Updated application settings')
refactoring of models names for repoGroup permissions
r1633 self.assertEqual(RhodeCodeSetting
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 .get_app_settings()['rhodecode_title'],
new_title.decode('utf-8'))
updated tests for application settings
r893
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 response = response.follow()
Renamed name to firstname in forms...
r2544 response.mustcontain("""<h1><a href="/">%s</a></h1>""" % new_title)
updated tests for application settings
r893
renamed project to rhodecode
r547 def test_my_account(self):
self.log_user()
response = self.app.get(url('admin_settings_my_account'))
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366
Use only mustcontain for testing response body
r3646 response.mustcontain('value="test_admin')
Refactor codes for scm model...
r691
Renamed name to firstname in forms...
r2544 @parameterized.expand([('firstname', 'new_username'),
('lastname', 'new_username'),
('admin', True),
('admin', False),
('ldap_dn', 'test'),
('ldap_dn', None),
('active', False),
('active', True),
('email', 'some@email.com'),
])
def test_my_account_update(self, name, expected):
uname = 'testme'
usr = UserModel().create_or_update(username=uname, password='qweqwe',
email='testme@rhodecod.org')
synced vcs with upstream...
r3797 Session().commit()
Renamed name to firstname in forms...
r2544 params = usr.get_api_data()
user_id = usr.user_id
self.log_user(username=uname, password='qweqwe')
params.update({name: expected})
params.update({'password_confirmation': ''})
params.update({'new_password': ''})
fixed test that broke admin email address
r754
Renamed name to firstname in forms...
r2544 try:
response = self.app.put(url('admin_settings_my_account_update',
id=user_id), params)
Refactor codes for scm model...
r691
Renamed name to firstname in forms...
r2544 self.checkSessionFlash(response,
'Your account was updated successfully')
updated_user = User.get_by_username(uname)
updated_params = updated_user.get_api_data()
updated_params.update({'password_confirmation': ''})
updated_params.update({'new_password': ''})
Refactor codes for scm model...
r691
Renamed name to firstname in forms...
r2544 params['last_login'] = updated_params['last_login']
if name == 'email':
params['emails'] = [expected]
if name == 'ldap_dn':
#cannot update this via form
params['ldap_dn'] = None
if name == 'active':
#my account cannot deactivate account
params['active'] = True
if name == 'admin':
#my account cannot make you an admin !
params['admin'] = False
fixed test that broke admin email address
r754
Renamed name to firstname in forms...
r2544 self.assertEqual(params, updated_params)
Added CheckSessionFlash into init....
r1382
Renamed name to firstname in forms...
r2544 finally:
UserModel().delete('testme')
Refactor codes for scm model...
r691
renamed project to rhodecode
r547 def test_my_account_update_err_email_exists(self):
self.log_user()
Refactor codes for scm model...
r691
Switched forms to new validators
r2467 new_email = 'test_regular@mail.com' # already exisitn email
Renamed name to firstname in forms...
r2544 response = self.app.put(url('admin_settings_my_account_update'),
params=dict(
username='test_admin',
new_password='test12',
password_confirmation='test122',
firstname='NewName',
lastname='NewLastname',
email=new_email,)
)
Refactor codes for scm model...
r691
Renamed name to firstname in forms...
r2544 response.mustcontain('This e-mail address is already taken')
Refactor codes for scm model...
r691
renamed project to rhodecode
r547 def test_my_account_update_err(self):
self.log_user('test_regular2', 'test12')
Refactor codes for scm model...
r691
renamed project to rhodecode
r547 new_email = 'newmail.pl'
Switched forms to new validators
r2467 response = self.app.post(url('admin_settings_my_account_update'),
params=dict(
_method='put',
username='test_admin',
new_password='test12',
password_confirmation='test122',
Renamed name to firstname in forms...
r2544 firstname='NewName',
Switched forms to new validators
r2467 lastname='NewLastname',
email=new_email,)
)
response.mustcontain('An email address must contain a single @')
from rhodecode.model import validators
msg = validators.ValidUsername(edit=False,
old_data={})._messages['username_exists']
msg = h.html_escape(msg % {'username': 'test_admin'})
response.mustcontain(u"%s" % msg)
Fixed issue #501 error on setting set_as_fork to same repo...
r2629
def test_set_repo_fork_has_no_self_id(self):
self.log_user()
repo = Repository.get_by_repo_name(HG_REPO)
response = self.app.get(url('edit_repo', repo_name=HG_REPO))
opt = """<option value="%s">vcs_test_git</option>""" % repo.repo_id
Use only mustcontain for testing response body
r3646 response.mustcontain(no=[opt])
Fixed issue #501 error on setting set_as_fork to same repo...
r2629
def test_set_fork_of_repo(self):
self.log_user()
repo = Repository.get_by_repo_name(HG_REPO)
repo2 = Repository.get_by_repo_name(GIT_REPO)
response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
params=dict(
id_fork_of=repo2.repo_id
))
repo = Repository.get_by_repo_name(HG_REPO)
repo2 = Repository.get_by_repo_name(GIT_REPO)
self.checkSessionFlash(response,
'Marked repo %s as fork of %s' % (repo.repo_name, repo2.repo_name))
assert repo.fork == repo2
response = response.follow()
# check if given repo is selected
opt = """<option value="%s" selected="selected">%s</option>""" % (
repo2.repo_id, repo2.repo_name)
response.mustcontain(opt)
# clean session flash
#response = self.app.get(url('edit_repo', repo_name=HG_REPO))
## mark it as None
response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
params=dict(
id_fork_of=None
))
repo = Repository.get_by_repo_name(HG_REPO)
repo2 = Repository.get_by_repo_name(GIT_REPO)
self.checkSessionFlash(response,
'Marked repo %s as fork of %s' % (repo.repo_name, "Nothing"))
replace equality comparision to None
r3889 assert repo.fork is None
Fixed issue #501 error on setting set_as_fork to same repo...
r2629
def test_set_fork_of_same_repo(self):
self.log_user()
repo = Repository.get_by_repo_name(HG_REPO)
response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
params=dict(
id_fork_of=repo.repo_id
))
self.checkSessionFlash(response,
white space cleanup
r2673 'An error occurred during this operation')