Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_settings.py @ 2544:6ce3387bf0ce beta
Renamed name to firstname in forms
- added multiple test for edit my account and edit user from admin
- fixed issues with update user accounts from admin
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 04 Jul 2012 18:13:25 +0200 |
parents | 4419551b2915 |
children | d2901d906ef3 |
rev | line source |
---|---|
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
1 # -*- coding: utf-8 -*- |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
2 |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
3 from rhodecode.lib.auth import get_crypt_password, check_password |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1597
diff
changeset
|
4 from rhodecode.model.db import User, RhodeCodeSetting |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
534
diff
changeset
|
5 from rhodecode.tests import * |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
6 from rhodecode.lib import helpers as h |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
7 from rhodecode.model.user import UserModel |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
8 |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
10 class TestAdminSettingsController(TestController): |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 def test_index(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 response = self.app.get(url('admin_settings')) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # Test response... |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 def test_index_as_xml(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 response = self.app.get(url('formatted_admin_settings', format='xml')) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 def test_create(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 response = self.app.post(url('admin_settings')) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 def test_new(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 response = self.app.get(url('admin_new_setting')) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 def test_new_as_xml(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 response = self.app.get(url('formatted_admin_new_setting', format='xml')) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 def test_update(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
29 response = self.app.put(url('admin_setting', setting_id=1)) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 def test_update_browser_fakeout(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
32 response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='put')) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 def test_delete(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
35 response = self.app.delete(url('admin_setting', setting_id=1)) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 def test_delete_browser_fakeout(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
38 response = self.app.post(url('admin_setting', setting_id=1), params=dict(_method='delete')) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 def test_show(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
41 response = self.app.get(url('admin_setting', setting_id=1)) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 def test_show_as_xml(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
44 response = self.app.get(url('formatted_admin_setting', setting_id=1, format='xml')) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 def test_edit(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
47 response = self.app.get(url('admin_edit_setting', setting_id=1)) |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 def test_edit_as_xml(self): |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
50 response = self.app.get(url('formatted_admin_edit_setting', |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
51 setting_id=1, format='xml')) |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
52 |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
53 def test_ga_code_active(self): |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
54 self.log_user() |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
55 old_title = 'RhodeCode' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
56 old_realm = 'RhodeCode authentication' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
57 new_ga_code = 'ga-test-123456789' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
58 response = self.app.post(url('admin_setting', setting_id='global'), |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
59 params=dict( |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
60 _method='put', |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
61 rhodecode_title=old_title, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
62 rhodecode_realm=old_realm, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
63 rhodecode_ga_code=new_ga_code |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
64 )) |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
65 |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
66 self.checkSessionFlash(response, 'Updated application settings') |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
67 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1597
diff
changeset
|
68 self.assertEqual(RhodeCodeSetting |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
69 .get_app_settings()['rhodecode_ga_code'], new_ga_code) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
70 |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
71 response = response.follow() |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
72 response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
73 |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
74 def test_ga_code_inactive(self): |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
75 self.log_user() |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
76 old_title = 'RhodeCode' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
77 old_realm = 'RhodeCode authentication' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
78 new_ga_code = '' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
79 response = self.app.post(url('admin_setting', setting_id='global'), |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
80 params=dict( |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
81 _method='put', |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
82 rhodecode_title=old_title, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
83 rhodecode_realm=old_realm, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
84 rhodecode_ga_code=new_ga_code |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
85 )) |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
86 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
87 self.assertTrue('Updated application settings' in |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
88 response.session['flash'][0][1]) |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1597
diff
changeset
|
89 self.assertEqual(RhodeCodeSetting |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
90 .get_app_settings()['rhodecode_ga_code'], new_ga_code) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
91 |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
92 response = response.follow() |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
93 self.assertFalse("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
94 in response.body) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
95 |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
96 def test_title_change(self): |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
97 self.log_user() |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
98 old_title = 'RhodeCode' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
99 new_title = old_title + '_changed' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
100 old_realm = 'RhodeCode authentication' |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
101 |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
102 for new_title in ['Changed', 'Żółwik', old_title]: |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
103 response = self.app.post(url('admin_setting', setting_id='global'), |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
104 params=dict( |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
105 _method='put', |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
106 rhodecode_title=new_title, |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
107 rhodecode_realm=old_realm, |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
108 rhodecode_ga_code='' |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
109 )) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
110 |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
111 self.checkSessionFlash(response, 'Updated application settings') |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1597
diff
changeset
|
112 self.assertEqual(RhodeCodeSetting |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
113 .get_app_settings()['rhodecode_title'], |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
114 new_title.decode('utf-8')) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
115 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
116 response = response.follow() |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
117 response.mustcontain("""<h1><a href="/">%s</a></h1>""" % new_title) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
118 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
119 def test_my_account(self): |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
120 self.log_user() |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
121 response = self.app.get(url('admin_settings_my_account')) |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
122 |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
123 self.assertTrue('value="test_admin' in response.body) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
124 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
125 @parameterized.expand([('firstname', 'new_username'), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
126 ('lastname', 'new_username'), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
127 ('admin', True), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
128 ('admin', False), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
129 ('ldap_dn', 'test'), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
130 ('ldap_dn', None), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
131 ('active', False), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
132 ('active', True), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
133 ('email', 'some@email.com'), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
134 ]) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
135 def test_my_account_update(self, name, expected): |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
136 uname = 'testme' |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
137 usr = UserModel().create_or_update(username=uname, password='qweqwe', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
138 email='testme@rhodecod.org') |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
139 self.Session().commit() |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
140 params = usr.get_api_data() |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
141 user_id = usr.user_id |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
142 self.log_user(username=uname, password='qweqwe') |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
143 params.update({name: expected}) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
144 params.update({'password_confirmation': ''}) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
145 params.update({'new_password': ''}) |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
146 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
147 try: |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
148 response = self.app.put(url('admin_settings_my_account_update', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
149 id=user_id), params) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
150 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
151 self.checkSessionFlash(response, |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
152 'Your account was updated successfully') |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
153 |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
154 updated_user = User.get_by_username(uname) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
155 updated_params = updated_user.get_api_data() |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
156 updated_params.update({'password_confirmation': ''}) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
157 updated_params.update({'new_password': ''}) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
158 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
159 params['last_login'] = updated_params['last_login'] |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
160 if name == 'email': |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
161 params['emails'] = [expected] |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
162 if name == 'ldap_dn': |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
163 #cannot update this via form |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
164 params['ldap_dn'] = None |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
165 if name == 'active': |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
166 #my account cannot deactivate account |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
167 params['active'] = True |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
168 if name == 'admin': |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
169 #my account cannot make you an admin ! |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
170 params['admin'] = False |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
171 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
172 self.assertEqual(params, updated_params) |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
173 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
174 finally: |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
175 UserModel().delete('testme') |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
176 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
177 def test_my_account_update_err_email_exists(self): |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
178 self.log_user() |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
179 |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
180 new_email = 'test_regular@mail.com' # already exisitn email |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
181 response = self.app.put(url('admin_settings_my_account_update'), |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
182 params=dict( |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
183 username='test_admin', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
184 new_password='test12', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
185 password_confirmation='test122', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
186 firstname='NewName', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
187 lastname='NewLastname', |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
188 email=new_email,) |
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
189 ) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
190 |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
191 response.mustcontain('This e-mail address is already taken') |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
192 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
193 def test_my_account_update_err(self): |
533
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
194 self.log_user('test_regular2', 'test12') |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
195 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
196 new_email = 'newmail.pl' |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
197 response = self.app.post(url('admin_settings_my_account_update'), |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
198 params=dict( |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
199 _method='put', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
200 username='test_admin', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
201 new_password='test12', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
202 password_confirmation='test122', |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2467
diff
changeset
|
203 firstname='NewName', |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
204 lastname='NewLastname', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
205 email=new_email,) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
206 ) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
207 |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
208 response.mustcontain('An email address must contain a single @') |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
209 from rhodecode.model import validators |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
210 msg = validators.ValidUsername(edit=False, |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
211 old_data={})._messages['username_exists'] |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
212 msg = h.html_escape(msg % {'username': 'test_admin'}) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
213 response.mustcontain(u"%s" % msg) |