annotate rhodecode/tests/functional/test_admin_settings.py @ 1382:c310e1e1e757 beta

Added CheckSessionFlash into init. Added repo_groups_test controller. Renamed users_groups test controller
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 14 Jun 2011 09:38:23 +0200
parents 9c0f5d558789
children 019026a8cf67
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
1292
c0335c1dee36 added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents: 893
diff changeset
4 from rhodecode.model.db import User, RhodeCodeSettings
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 534
diff changeset
5 from rhodecode.tests import *
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
7 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
8
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 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
10 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
11 # Test response...
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_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
14 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
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_create(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.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
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_new(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.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
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_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
23 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
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_update(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
26 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
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_browser_fakeout(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
29 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
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_delete(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
32 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
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_browser_fakeout(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
35 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
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_show(self):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
38 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
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_as_xml(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('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
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_edit(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('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
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_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
47 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
48 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
49
893
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
50
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
51 def test_ga_code_active(self):
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
52 self.log_user()
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
53 old_title = 'RhodeCode'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
54 old_realm = 'RhodeCode authentication'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
55 new_ga_code = 'ga-test-123456789'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
56 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
57 params=dict(
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
58 _method='put',
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
59 rhodecode_title=old_title,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
60 rhodecode_realm=old_realm,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
61 rhodecode_ga_code=new_ga_code
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
62 ))
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
63
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
64 self.checkSessionFlash(response, 'Updated application settings')
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
65
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
66 self.assertEqual(RhodeCodeSettings
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
67 .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
68
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
69 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
70 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
71 in response.body)
893
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
72
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
73 def test_ga_code_inactive(self):
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
74 self.log_user()
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
75 old_title = 'RhodeCode'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
76 old_realm = 'RhodeCode authentication'
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
77 new_ga_code = ''
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
78 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
79 params=dict(
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
80 _method='put',
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
81 rhodecode_title=old_title,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
82 rhodecode_realm=old_realm,
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
83 rhodecode_ga_code=new_ga_code
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
84 ))
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
85
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
86 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
87 response.session['flash'][0][1])
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 self.assertEqual(RhodeCodeSettings
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
89 .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
90
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
91 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
92 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
93 not in response.body)
893
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
94
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')
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
112 self.assertEqual(RhodeCodeSettings
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
ead7be02283b updated tests for application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 782
diff changeset
120
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
121 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
122 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
123 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
124
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
125 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
126
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
127 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
128 self.log_user()
754
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
129
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
130 new_email = 'new@mail.pl'
754
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
131 new_name = 'NewName'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
132 new_lastname = 'NewLastname'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
133 new_password = 'test123'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
134
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
135
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
136 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
137 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
138 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
139 new_password=new_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 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
141 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
142 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
143 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
144 response.follow()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
145
782
51127b2efb33 fixed broken test after latest changes
Marcin Kuzminski <marcin@python-works.com>
parents: 754
diff changeset
146 assert 'Your account was updated successfully' in response.session['flash'][0][1], 'no flash message about success of change'
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
147 user = self.sa.query(User).filter(User.username == 'test_admin').one()
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
148 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
149 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
150 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
151 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
152
754
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
153 #bring back the admin settings
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
154 old_email = 'test_admin@mail.com'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
155 old_name = 'RhodeCode'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
156 old_lastname = 'Admin'
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
157 old_password = 'test12'
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
158
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
159 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
160 _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
161 username='test_admin',
754
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
162 new_password=old_password,
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
754
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
172 user = self.sa.query(User).filter(User.username == 'test_admin').one()
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
173 assert user.email == old_email , 'incorrect user email after update got %s vs %s' % (user.email, old_email)
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
174
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
175 assert user.email == old_email , 'incorrect user email after update got %s vs %s' % (user.email, old_email)
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)
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
178 assert check_password(old_password, user.password) is True , 'password updated field mismatch %s vs %s' % (user.password, old_password)
101a407827e8 fixed test that broke admin email address
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
179
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
180
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
181 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
182 self.log_user()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
183
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 new_email = 'test_regular@mail.com'#already exisitn email
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 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
186 _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
187 username='test_admin',
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 491
diff changeset
188 new_password='test12',
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
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 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
197 self.log_user('test_regular2', 'test12')
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
198
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
199 new_email = 'newmail.pl'
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
200 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
201 _method='put',
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 491
diff changeset
202 username='test_admin',
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 491
diff changeset
203 new_password='test12',
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
204 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
205 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
206 email=new_email,))
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
207 assert 'An email address must contain a single @' in response.body, 'Missing error message about wrong email'
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
208 assert 'This username already exists' in response.body, 'Missing error message about existing user'