##// END OF EJS Templates
updated tests for application settings
marcink -
r893:ead7be02 beta
parent child Browse files
Show More
@@ -1,6 +1,7 b''
1 from rhodecode.lib.auth import get_crypt_password, check_password
1 from rhodecode.lib.auth import get_crypt_password, check_password
2 from rhodecode.model.db import User
2 from rhodecode.model.db import User
3 from rhodecode.tests import *
3 from rhodecode.tests import *
4 from rhodecode.model.settings import SettingsModel
4
5
5 class TestAdminSettingsController(TestController):
6 class TestAdminSettingsController(TestController):
6
7
@@ -44,14 +45,73 b' class TestAdminSettingsController(TestCo'
44 def test_edit_as_xml(self):
45 def test_edit_as_xml(self):
45 response = self.app.get(url('formatted_admin_edit_setting', setting_id=1, format='xml'))
46 response = self.app.get(url('formatted_admin_edit_setting', setting_id=1, format='xml'))
46
47
48
49 def test_ga_code_active(self):
50 self.log_user()
51 old_title = 'RhodeCode'
52 old_realm = 'RhodeCode authentication'
53 new_ga_code = 'ga-test-123456789'
54 response = self.app.post(url('admin_setting', setting_id='global'),
55 params=dict(
56 _method='put',
57 rhodecode_title=old_title,
58 rhodecode_realm=old_realm,
59 rhodecode_ga_code=new_ga_code
60 ))
61
62 assert 'Updated application settings' in response.session['flash'][0][1], 'no flash message about success of change'
63 assert SettingsModel(self.sa).get_app_settings()['rhodecode_ga_code'] == new_ga_code, 'change not in database'
64
65 response = response.follow()
66 assert """_gaq.push(['_setAccount', '%s']);""" % new_ga_code in response.body
67
68 def test_ga_code_inactive(self):
69 self.log_user()
70 old_title = 'RhodeCode'
71 old_realm = 'RhodeCode authentication'
72 new_ga_code = ''
73 response = self.app.post(url('admin_setting', setting_id='global'),
74 params=dict(
75 _method='put',
76 rhodecode_title=old_title,
77 rhodecode_realm=old_realm,
78 rhodecode_ga_code=new_ga_code
79 ))
80
81 assert 'Updated application settings' in response.session['flash'][0][1], 'no flash message about success of change'
82 assert SettingsModel(self.sa).get_app_settings()['rhodecode_ga_code'] == new_ga_code, 'change not in database'
83
84 response = response.follow()
85 assert """_gaq.push(['_setAccount', '%s']);""" % new_ga_code not in response.body
86
87
88 def test_title_change(self):
89 self.log_user()
90 old_title = 'RhodeCode'
91 new_title = old_title + '_changed'
92 old_realm = 'RhodeCode authentication'
93 response = self.app.post(url('admin_setting', setting_id='global'),
94 params=dict(
95 _method='put',
96 rhodecode_title=new_title,
97 rhodecode_realm=old_realm,
98 rhodecode_ga_code=''
99 ))
100
101
102 assert 'Updated application settings' in response.session['flash'][0][1], 'no flash message about success of change'
103 assert SettingsModel(self.sa).get_app_settings()['rhodecode_title'] == new_title, 'change not in database'
104
105 response = response.follow()
106 assert """<h1><a href="/">%s</a></h1>""" % new_title in response.body
107
108
47 def test_my_account(self):
109 def test_my_account(self):
48 self.log_user()
110 self.log_user()
49 response = self.app.get(url('admin_settings_my_account'))
111 response = self.app.get(url('admin_settings_my_account'))
50 print response
112 print response
51 assert 'value="test_admin' in response.body
113 assert 'value="test_admin' in response.body
52
114
53
54
55 def test_my_account_update(self):
115 def test_my_account_update(self):
56 self.log_user()
116 self.log_user()
57
117
@@ -115,7 +175,6 b' class TestAdminSettingsController(TestCo'
115 name='NewName',
175 name='NewName',
116 lastname='NewLastname',
176 lastname='NewLastname',
117 email=new_email,))
177 email=new_email,))
118 print response
119
178
120 assert 'This e-mail address is already taken' in response.body, 'Missing error message about existing email'
179 assert 'This e-mail address is already taken' in response.body, 'Missing error message about existing email'
121
180
@@ -131,6 +190,5 b' class TestAdminSettingsController(TestCo'
131 name='NewName',
190 name='NewName',
132 lastname='NewLastname',
191 lastname='NewLastname',
133 email=new_email,))
192 email=new_email,))
134 print response
135 assert 'An email address must contain a single @' in response.body, 'Missing error message about wrong email'
193 assert 'An email address must contain a single @' in response.body, 'Missing error message about wrong email'
136 assert 'This username already exists' in response.body, 'Missing error message about existing user'
194 assert 'This username already exists' in response.body, 'Missing error message about existing user'
General Comments 0
You need to be logged in to leave comments. Login now