Mercurial > kallithea
annotate 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 |
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 |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
7 |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
9 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
|
10 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 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
|
12 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
|
13 # Test response... |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 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
|
16 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
|
17 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 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
|
19 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
|
20 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 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
|
22 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
|
23 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 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
|
25 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
|
26 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 def test_update(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
28 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
|
29 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 def test_update_browser_fakeout(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
31 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
|
32 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 def test_delete(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
34 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
|
35 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 def test_delete_browser_fakeout(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
37 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
|
38 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 def test_show(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
40 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
|
41 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 def test_show_as_xml(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
43 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
|
44 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 def test_edit(self): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
46 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
|
47 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
52 def test_ga_code_active(self): |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
53 self.log_user() |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
54 old_title = 'RhodeCode' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
55 old_realm = 'RhodeCode authentication' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
56 new_ga_code = 'ga-test-123456789' |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
57 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
|
58 params=dict( |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
59 _method='put', |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
60 rhodecode_title=old_title, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
61 rhodecode_realm=old_realm, |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
62 rhodecode_ga_code=new_ga_code |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
63 )) |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
64 |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
65 self.checkSessionFlash(response, 'Updated application settings') |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
66 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1597
diff
changeset
|
67 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
|
68 .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
|
69 |
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
70 response = response.follow() |
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
|
71 self.assertTrue("""_gaq.push(['_setAccount', '%s']);""" % new_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
|
72 in response.body) |
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() |
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
|
93 self.assertTrue("""_gaq.push(['_setAccount', '%s']);""" % new_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
|
94 not 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() |
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
|
117 self.assertTrue("""<h1><a href="/">%s</a></h1>""" % 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
|
118 in response.body) |
893
ead7be02283b
updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
782
diff
changeset
|
119 |
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
|
120 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
|
121 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
|
122 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
|
123 |
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
|
124 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
|
125 |
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
|
126 def test_my_account_update(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
|
127 self.log_user() |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
128 |
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
|
129 new_email = 'new@mail.pl' |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
130 new_name = 'NewName' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
131 new_lastname = 'NewLastname' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
132 new_password = 'test123' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
133 |
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
|
134 response = self.app.post(url('admin_settings_my_account_update'), |
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
|
135 params=dict(_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
|
136 username='test_admin', |
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
|
137 new_password=new_password, |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
138 password_confirmation=new_password, |
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
|
139 password='', |
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
|
140 name=new_name, |
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
|
141 lastname=new_lastname, |
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
|
142 email=new_email,)) |
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
|
143 response.follow() |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
144 |
782
51127b2efb33
fixed broken test after latest changes
Marcin Kuzminski <marcin@python-works.com>
parents:
754
diff
changeset
|
145 assert 'Your account was updated successfully' in response.session['flash'][0][1], 'no flash message about success of change' |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
146 user = self.Session.query(User).filter(User.username == 'test_admin').one() |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
147 assert user.email == new_email, 'incorrect user email after update got %s vs %s' % (user.email, new_email) |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
148 assert user.name == new_name, 'updated field mismatch %s vs %s' % (user.name, new_name) |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
149 assert user.lastname == new_lastname, 'updated field mismatch %s vs %s' % (user.lastname, new_lastname) |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
150 assert check_password(new_password, user.password) is True, 'password field mismatch %s vs %s' % (user.password, new_password) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
151 |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
152 #bring back the admin settings |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
153 old_email = 'test_admin@mail.com' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
154 old_name = 'RhodeCode' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
155 old_lastname = 'Admin' |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
156 old_password = 'test12' |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
157 |
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
|
158 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
159 _method='put', |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
160 username='test_admin', |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
161 new_password=old_password, |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
162 password_confirmation=old_password, |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
163 password='', |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
164 name=old_name, |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
165 lastname=old_lastname, |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
166 email=old_email,)) |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
167 |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
168 response.follow() |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
169 self.checkSessionFlash(response, |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
170 'Your account was updated successfully') |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
171 |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
172 user = self.Session.query(User).filter(User.username == 'test_admin').one() |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
173 assert user.email == old_email, 'incorrect user email after update got %s vs %s' % (user.email, old_email) |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
174 |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
175 assert user.email == old_email, 'incorrect user email after update got %s vs %s' % (user.email, old_email) |
754
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
176 assert user.name == old_name, 'updated field mismatch %s vs %s' % (user.name, old_name) |
101a407827e8
fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
177 assert user.lastname == old_lastname, 'updated field mismatch %s vs %s' % (user.lastname, old_lastname) |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
178 assert check_password(old_password, user.password) is True, 'password updated field mismatch %s vs %s' % (user.password, old_password) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
179 |
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
|
180 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
|
181 self.log_user() |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
182 |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
183 new_email = 'test_regular@mail.com' # already exisitn email |
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
|
184 response = self.app.post(url('admin_settings_my_account_update'), params=dict( |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
185 _method='put', |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
186 username='test_admin', |
533
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
187 new_password='test12', |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
188 password_confirmation='test122', |
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
|
189 name='NewName', |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
190 lastname='NewLastname', |
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
191 email=new_email,)) |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
192 |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
193 assert 'This e-mail address is already taken' in response.body, 'Missing error message about existing email' |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
194 |
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
|
195 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
|
196 self.log_user('test_regular2', 'test12') |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
197 |
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
|
198 new_email = 'newmail.pl' |
2467
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
199 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
|
200 params=dict( |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
201 _method='put', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
202 username='test_admin', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
203 new_password='test12', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
204 password_confirmation='test122', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
205 name='NewName', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
206 lastname='NewLastname', |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
207 email=new_email,) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
208 ) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
209 |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
210 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
|
211 from rhodecode.model import validators |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
212 msg = validators.ValidUsername(edit=False, |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
213 old_data={})._messages['username_exists'] |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
214 msg = h.html_escape(msg % {'username': 'test_admin'}) |
4419551b2915
Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
215 response.mustcontain(u"%s" % msg) |