annotate rhodecode/tests/functional/test_admin_settings.py @ 3645:aef5f5ce5ead beta

use fixtures for forking
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 31 Mar 2013 21:31:36 +0200
parents 4f80df0d45c8
children 63e49418a4cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
2629
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository
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
2629
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
8 from rhodecode.model.scm import ScmModel
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
9
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
11 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
12
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 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
14 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
15 # Test response...
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 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
18 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
19
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 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
21 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
22
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 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
24 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
25
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 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
27 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
28
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 def test_update(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
30 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
31
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 def test_update_browser_fakeout(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
33 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
34
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 def test_delete(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
36 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
37
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 def test_delete_browser_fakeout(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
39 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
40
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 def test_show(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
42 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
43
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 def test_show_as_xml(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
45 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
46
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 def test_edit(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
48 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
49
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 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
51 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
52 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
53
893
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
54 def test_ga_code_active(self):
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
55 self.log_user()
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
56 old_title = 'RhodeCode'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
57 old_realm = 'RhodeCode authentication'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
58 new_ga_code = 'ga-test-123456789'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
59 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
60 params=dict(
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
61 _method='put',
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
62 rhodecode_title=old_title,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
63 rhodecode_realm=old_realm,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
64 rhodecode_ga_code=new_ga_code
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
65 ))
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
66
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
67 self.checkSessionFlash(response, 'Updated application settings')
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
68
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1597
diff changeset
69 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
70 .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
71
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
72 response = response.follow()
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
73 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
74
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
75 def test_ga_code_inactive(self):
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
76 self.log_user()
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
77 old_title = 'RhodeCode'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
78 old_realm = 'RhodeCode authentication'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
79 new_ga_code = ''
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
80 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
81 params=dict(
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
82 _method='put',
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
83 rhodecode_title=old_title,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
84 rhodecode_realm=old_realm,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
85 rhodecode_ga_code=new_ga_code
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
86 ))
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
87
3640
4f80df0d45c8 unified flash msg tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2673
diff changeset
88 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
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)
2629
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
214
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
215 def test_set_repo_fork_has_no_self_id(self):
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
216 self.log_user()
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
217 repo = Repository.get_by_repo_name(HG_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
218 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
219 opt = """<option value="%s">vcs_test_git</option>""" % repo.repo_id
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
220 assert opt not in response.body
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
221
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
222 def test_set_fork_of_repo(self):
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
223 self.log_user()
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
224 repo = Repository.get_by_repo_name(HG_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
225 repo2 = Repository.get_by_repo_name(GIT_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
226 response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
227 params=dict(
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
228 id_fork_of=repo2.repo_id
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
229 ))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
230 repo = Repository.get_by_repo_name(HG_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
231 repo2 = Repository.get_by_repo_name(GIT_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
232 self.checkSessionFlash(response,
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
233 'Marked repo %s as fork of %s' % (repo.repo_name, repo2.repo_name))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
234
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
235 assert repo.fork == repo2
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
236 response = response.follow()
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
237 # check if given repo is selected
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
238
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
239 opt = """<option value="%s" selected="selected">%s</option>""" % (
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
240 repo2.repo_id, repo2.repo_name)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
241 response.mustcontain(opt)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
242
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
243 # clean session flash
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
244 #response = self.app.get(url('edit_repo', repo_name=HG_REPO))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
245
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
246 ## mark it as None
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
247 response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
248 params=dict(
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
249 id_fork_of=None
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
250 ))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
251 repo = Repository.get_by_repo_name(HG_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
252 repo2 = Repository.get_by_repo_name(GIT_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
253 self.checkSessionFlash(response,
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
254 'Marked repo %s as fork of %s' % (repo.repo_name, "Nothing"))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
255 assert repo.fork == None
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
256
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
257 def test_set_fork_of_same_repo(self):
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
258 self.log_user()
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
259 repo = Repository.get_by_repo_name(HG_REPO)
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
260 response = self.app.put(url('repo_as_fork', repo_name=HG_REPO),
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
261 params=dict(
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
262 id_fork_of=repo.repo_id
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
263 ))
d2901d906ef3 Fixed issue #501 error on setting set_as_fork to same repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
264 self.checkSessionFlash(response,
2673
d5e42c00f3c1 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2629
diff changeset
265 'An error occurred during this operation')