Mercurial > kallithea
comparison rhodecode/tests/functional/test_admin_settings.py @ 691:7486da5f0628 beta
Refactor codes for scm model
Some test updates, added test for admin user controller
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 14 Nov 2010 22:54:16 +0100 |
parents | 1e757ac98988 |
children | 18a3ca35d501 |
comparison
equal
deleted
inserted
replaced
690:4685f3eafd35 | 691:7486da5f0628 |
---|---|
1 from rhodecode.tests import * | 1 from rhodecode.tests import * |
2 from rhodecode.model.db import User | 2 from rhodecode.model.db import User |
3 | 3 |
4 class TestSettingsController(TestController): | 4 class TestAdminSettingsController(TestController): |
5 | 5 |
6 def test_index(self): | 6 def test_index(self): |
7 response = self.app.get(url('admin_settings')) | 7 response = self.app.get(url('admin_settings')) |
8 # Test response... | 8 # Test response... |
9 | 9 |
46 def test_my_account(self): | 46 def test_my_account(self): |
47 self.log_user() | 47 self.log_user() |
48 response = self.app.get(url('admin_settings_my_account')) | 48 response = self.app.get(url('admin_settings_my_account')) |
49 print response | 49 print response |
50 assert 'value="test_admin' in response.body | 50 assert 'value="test_admin' in response.body |
51 | 51 |
52 | 52 |
53 | 53 |
54 def test_my_account_update(self): | 54 def test_my_account_update(self): |
55 self.log_user() | 55 self.log_user() |
56 new_email = 'new@mail.pl' | 56 new_email = 'new@mail.pl' |
57 response = self.app.post(url('admin_settings_my_account_update'), params=dict( | 57 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
58 _method='put', | 58 _method='put', |
62 name='NewName', | 62 name='NewName', |
63 lastname='NewLastname', | 63 lastname='NewLastname', |
64 email=new_email,)) | 64 email=new_email,)) |
65 response.follow() | 65 response.follow() |
66 print response | 66 print response |
67 | 67 |
68 print 'x' * 100 | 68 print 'x' * 100 |
69 print response.session | 69 print response.session |
70 assert 'Your account was updated succesfully' in response.session['flash'][0][1], 'no flash message about success of change' | 70 assert 'Your account was updated succesfully' in response.session['flash'][0][1], 'no flash message about success of change' |
71 user = self.sa.query(User).filter(User.username == 'test_admin').one() | 71 user = self.sa.query(User).filter(User.username == 'test_admin').one() |
72 assert user.email == new_email , 'incorrect user email after update got %s vs %s' % (user.email, new_email) | 72 assert user.email == new_email , 'incorrect user email after update got %s vs %s' % (user.email, new_email) |
73 | 73 |
74 def test_my_account_update_own_email_ok(self): | 74 def test_my_account_update_own_email_ok(self): |
75 self.log_user() | 75 self.log_user() |
76 | 76 |
77 new_email = 'new@mail.pl' | 77 new_email = 'new@mail.pl' |
78 response = self.app.post(url('admin_settings_my_account_update'), params=dict( | 78 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
79 _method='put', | 79 _method='put', |
80 username='test_admin', | 80 username='test_admin', |
81 new_password='test12', | 81 new_password='test12', |
82 name='NewName', | 82 name='NewName', |
83 lastname='NewLastname', | 83 lastname='NewLastname', |
84 email=new_email,)) | 84 email=new_email,)) |
85 print response | 85 print response |
86 | 86 |
87 def test_my_account_update_err_email_exists(self): | 87 def test_my_account_update_err_email_exists(self): |
88 self.log_user() | 88 self.log_user() |
89 | 89 |
90 new_email = 'test_regular@mail.com'#already exisitn email | 90 new_email = 'test_regular@mail.com'#already exisitn email |
91 response = self.app.post(url('admin_settings_my_account_update'), params=dict( | 91 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
92 _method='put', | 92 _method='put', |
93 username='test_admin', | 93 username='test_admin', |
94 new_password='test12', | 94 new_password='test12', |
95 name='NewName', | 95 name='NewName', |
96 lastname='NewLastname', | 96 lastname='NewLastname', |
97 email=new_email,)) | 97 email=new_email,)) |
98 print response | 98 print response |
99 | 99 |
100 assert 'That e-mail address is already taken' in response.body, 'Missing error message about existing email' | 100 assert 'That e-mail address is already taken' in response.body, 'Missing error message about existing email' |
101 | 101 |
102 | 102 |
103 def test_my_account_update_err(self): | 103 def test_my_account_update_err(self): |
104 self.log_user('test_regular2', 'test12') | 104 self.log_user('test_regular2', 'test12') |
105 | 105 |
106 new_email = 'newmail.pl' | 106 new_email = 'newmail.pl' |
107 response = self.app.post(url('admin_settings_my_account_update'), params=dict( | 107 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
108 _method='put', | 108 _method='put', |
109 username='test_admin', | 109 username='test_admin', |
110 new_password='test12', | 110 new_password='test12', |