comparison kallithea/tests/functional/test_admin_settings.py @ 8687:5e46f73f0d1c

model: always import the whole db module - drop "from" imports
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 12 Oct 2020 11:12:37 +0200
parents 9bf701b246ba
children 761efb9624fa
comparison
equal deleted inserted replaced
8686:b095e2fbba44 8687:5e46f73f0d1c
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 from kallithea.model.db import Setting, Ui 3 from kallithea.model import db
4 from kallithea.tests import base 4 from kallithea.tests import base
5 from kallithea.tests.fixture import Fixture 5 from kallithea.tests.fixture import Fixture
6 6
7 7
8 fixture = Fixture() 8 fixture = Fixture()
78 self.checkSessionFlash(response, 'Added new hook') 78 self.checkSessionFlash(response, 'Added new hook')
79 response = response.follow() 79 response = response.follow()
80 response.mustcontain('test_hooks_2') 80 response.mustcontain('test_hooks_2')
81 response.mustcontain('cd %s2' % base.TESTS_TMP_PATH) 81 response.mustcontain('cd %s2' % base.TESTS_TMP_PATH)
82 82
83 hook_id = Ui.get_by_key('hooks', 'test_hooks_2').ui_id 83 hook_id = db.Ui.get_by_key('hooks', 'test_hooks_2').ui_id
84 ## delete 84 ## delete
85 self.app.post(base.url('admin_settings_hooks'), 85 self.app.post(base.url('admin_settings_hooks'),
86 params=dict(hook_id=hook_id, _session_csrf_secret_token=self.session_csrf_secret_token())) 86 params=dict(hook_id=hook_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
87 response = self.app.get(base.url('admin_settings_hooks')) 87 response = self.app.get(base.url('admin_settings_hooks'))
88 response.mustcontain(no=['test_hooks_2']) 88 response.mustcontain(no=['test_hooks_2'])
122 _session_csrf_secret_token=self.session_csrf_secret_token(), 122 _session_csrf_secret_token=self.session_csrf_secret_token(),
123 )) 123 ))
124 124
125 self.checkSessionFlash(response, 'Updated application settings') 125 self.checkSessionFlash(response, 'Updated application settings')
126 126
127 assert Setting.get_app_settings()['ga_code'] == new_ga_code 127 assert db.Setting.get_app_settings()['ga_code'] == new_ga_code
128 128
129 response = response.follow() 129 response = response.follow()
130 response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code) 130 response.mustcontain("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code)
131 131
132 def test_ga_code_inactive(self): 132 def test_ga_code_inactive(self):
142 captcha_public_key='', 142 captcha_public_key='',
143 _session_csrf_secret_token=self.session_csrf_secret_token(), 143 _session_csrf_secret_token=self.session_csrf_secret_token(),
144 )) 144 ))
145 145
146 self.checkSessionFlash(response, 'Updated application settings') 146 self.checkSessionFlash(response, 'Updated application settings')
147 assert Setting.get_app_settings()['ga_code'] == new_ga_code 147 assert db.Setting.get_app_settings()['ga_code'] == new_ga_code
148 148
149 response = response.follow() 149 response = response.follow()
150 response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code]) 150 response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])
151 151
152 def test_captcha_activate(self): 152 def test_captcha_activate(self):
162 captcha_public_key='1234567890', 162 captcha_public_key='1234567890',
163 _session_csrf_secret_token=self.session_csrf_secret_token(), 163 _session_csrf_secret_token=self.session_csrf_secret_token(),
164 )) 164 ))
165 165
166 self.checkSessionFlash(response, 'Updated application settings') 166 self.checkSessionFlash(response, 'Updated application settings')
167 assert Setting.get_app_settings()['captcha_private_key'] == '1234567890' 167 assert db.Setting.get_app_settings()['captcha_private_key'] == '1234567890'
168 168
169 response = self.app.get(base.url('register')) 169 response = self.app.get(base.url('register'))
170 response.mustcontain('captcha') 170 response.mustcontain('captcha')
171 171
172 def test_captcha_deactivate(self): 172 def test_captcha_deactivate(self):
182 captcha_public_key='1234567890', 182 captcha_public_key='1234567890',
183 _session_csrf_secret_token=self.session_csrf_secret_token(), 183 _session_csrf_secret_token=self.session_csrf_secret_token(),
184 )) 184 ))
185 185
186 self.checkSessionFlash(response, 'Updated application settings') 186 self.checkSessionFlash(response, 'Updated application settings')
187 assert Setting.get_app_settings()['captcha_private_key'] == '' 187 assert db.Setting.get_app_settings()['captcha_private_key'] == ''
188 188
189 response = self.app.get(base.url('register')) 189 response = self.app.get(base.url('register'))
190 response.mustcontain(no=['captcha']) 190 response.mustcontain(no=['captcha'])
191 191
192 def test_title_change(self): 192 def test_title_change(self):
204 captcha_public_key='', 204 captcha_public_key='',
205 _session_csrf_secret_token=self.session_csrf_secret_token(), 205 _session_csrf_secret_token=self.session_csrf_secret_token(),
206 )) 206 ))
207 207
208 self.checkSessionFlash(response, 'Updated application settings') 208 self.checkSessionFlash(response, 'Updated application settings')
209 assert Setting.get_app_settings()['title'] == new_title 209 assert db.Setting.get_app_settings()['title'] == new_title
210 210
211 response = response.follow() 211 response = response.follow()
212 response.mustcontain("""<span class="branding">%s</span>""" % new_title) 212 response.mustcontain("""<span class="branding">%s</span>""" % new_title)