Mercurial > kallithea
diff rhodecode/tests/functional/test_admin_settings.py @ 2467:4419551b2915 codereview
Switched forms to new validators
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 17 Jun 2012 21:37:07 +0200 |
parents | 8ecc6b8229a5 |
children | 6ce3387bf0ce |
line wrap: on
line diff
--- a/rhodecode/tests/functional/test_admin_settings.py Sun Jun 17 21:31:31 2012 +0200 +++ b/rhodecode/tests/functional/test_admin_settings.py Sun Jun 17 21:37:07 2012 +0200 @@ -3,6 +3,8 @@ from rhodecode.lib.auth import get_crypt_password, check_password from rhodecode.model.db import User, RhodeCodeSetting from rhodecode.tests import * +from rhodecode.lib import helpers as h + class TestAdminSettingsController(TestController): @@ -47,7 +49,6 @@ response = self.app.get(url('formatted_admin_edit_setting', setting_id=1, format='xml')) - def test_ga_code_active(self): self.log_user() old_title = 'RhodeCode' @@ -92,7 +93,6 @@ self.assertTrue("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code not in response.body) - def test_title_change(self): self.log_user() old_title = 'RhodeCode' @@ -117,7 +117,6 @@ self.assertTrue("""<h1><a href="/">%s</a></h1>""" % new_title in response.body) - def test_my_account(self): self.log_user() response = self.app.get(url('admin_settings_my_account')) @@ -132,12 +131,11 @@ new_lastname = 'NewLastname' new_password = 'test123' - response = self.app.post(url('admin_settings_my_account_update'), params=dict(_method='put', username='test_admin', new_password=new_password, - password_confirmation = new_password, + password_confirmation=new_password, password='', name=new_name, lastname=new_lastname, @@ -146,7 +144,7 @@ assert 'Your account was updated successfully' in response.session['flash'][0][1], 'no flash message about success of change' user = self.Session.query(User).filter(User.username == 'test_admin').one() - assert user.email == new_email , 'incorrect user email after update got %s vs %s' % (user.email, new_email) + assert user.email == new_email, 'incorrect user email after update got %s vs %s' % (user.email, new_email) assert user.name == new_name, 'updated field mismatch %s vs %s' % (user.name, new_name) assert user.lastname == new_lastname, 'updated field mismatch %s vs %s' % (user.lastname, new_lastname) assert check_password(new_password, user.password) is True, 'password field mismatch %s vs %s' % (user.password, new_password) @@ -161,7 +159,7 @@ _method='put', username='test_admin', new_password=old_password, - password_confirmation = old_password, + password_confirmation=old_password, password='', name=old_name, lastname=old_lastname, @@ -172,41 +170,46 @@ 'Your account was updated successfully') user = self.Session.query(User).filter(User.username == 'test_admin').one() - assert user.email == old_email , 'incorrect user email after update got %s vs %s' % (user.email, old_email) + assert user.email == old_email, 'incorrect user email after update got %s vs %s' % (user.email, old_email) - assert user.email == old_email , 'incorrect user email after update got %s vs %s' % (user.email, old_email) + assert user.email == old_email, 'incorrect user email after update got %s vs %s' % (user.email, old_email) assert user.name == old_name, 'updated field mismatch %s vs %s' % (user.name, old_name) assert user.lastname == old_lastname, 'updated field mismatch %s vs %s' % (user.lastname, old_lastname) - assert check_password(old_password, user.password) is True , 'password updated field mismatch %s vs %s' % (user.password, old_password) - + assert check_password(old_password, user.password) is True, 'password updated field mismatch %s vs %s' % (user.password, old_password) def test_my_account_update_err_email_exists(self): self.log_user() - new_email = 'test_regular@mail.com'#already exisitn email + new_email = 'test_regular@mail.com' # already exisitn email response = self.app.post(url('admin_settings_my_account_update'), params=dict( _method='put', username='test_admin', new_password='test12', - password_confirmation = 'test122', + password_confirmation='test122', name='NewName', lastname='NewLastname', email=new_email,)) assert 'This e-mail address is already taken' in response.body, 'Missing error message about existing email' - def test_my_account_update_err(self): self.log_user('test_regular2', 'test12') new_email = 'newmail.pl' - response = self.app.post(url('admin_settings_my_account_update'), params=dict( - _method='put', - username='test_admin', - new_password='test12', - password_confirmation = 'test122', - name='NewName', - lastname='NewLastname', - email=new_email,)) - assert 'An email address must contain a single @' in response.body, 'Missing error message about wrong email' - assert 'This username already exists' in response.body, 'Missing error message about existing user' + response = self.app.post(url('admin_settings_my_account_update'), + params=dict( + _method='put', + username='test_admin', + new_password='test12', + password_confirmation='test122', + name='NewName', + 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)