tests: fix test per appinfo/configure changes
This commit is contained in:
parent
2b3d69a379
commit
013d921772
|
@ -1528,42 +1528,50 @@ class TestMasterView(WebTestCase):
|
|||
get_index_url=MagicMock(return_value='/appinfo/'),
|
||||
configure_get_simple_settings=MagicMock(return_value=settings)):
|
||||
|
||||
# get the form page
|
||||
response = view.configure(session=self.session)
|
||||
self.assertIsInstance(response, Response)
|
||||
# nb. appinfo/configure template requires menu_handlers
|
||||
original_context = view.configure_get_context
|
||||
def get_context(**kw):
|
||||
kw = original_context(**kw)
|
||||
kw['menu_handlers'] = []
|
||||
return kw
|
||||
with patch.object(view, 'configure_get_context', new=get_context):
|
||||
|
||||
# post request to save settings
|
||||
self.request.method = 'POST'
|
||||
self.request.POST = {
|
||||
'wutta.app_title': 'Wutta',
|
||||
'wutta.foo': 'bar',
|
||||
'wutta.flag': 'true',
|
||||
}
|
||||
response = view.configure(session=self.session)
|
||||
# nb. should get redirect back to configure page
|
||||
self.assertEqual(response.status_code, 302)
|
||||
# get the form page
|
||||
response = view.configure(session=self.session)
|
||||
self.assertIsInstance(response, Response)
|
||||
|
||||
# should now have 5 settings
|
||||
count = self.session.query(model.Setting).count()
|
||||
self.assertEqual(count, 5)
|
||||
get_setting = functools.partial(self.app.get_setting, self.session)
|
||||
self.assertEqual(get_setting('wutta.app_title'), 'Wutta')
|
||||
self.assertEqual(get_setting('wutta.foo'), 'bar')
|
||||
self.assertEqual(get_setting('wutta.flag'), 'true')
|
||||
self.assertEqual(get_setting('wutta.number'), '42')
|
||||
self.assertEqual(get_setting('wutta.value1'), '')
|
||||
self.assertEqual(get_setting('wutta.value2'), None)
|
||||
# post request to save settings
|
||||
self.request.method = 'POST'
|
||||
self.request.POST = {
|
||||
'wutta.app_title': 'Wutta',
|
||||
'wutta.foo': 'bar',
|
||||
'wutta.flag': 'true',
|
||||
}
|
||||
response = view.configure(session=self.session)
|
||||
# nb. should get redirect back to configure page
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# post request to remove settings
|
||||
self.request.method = 'POST'
|
||||
self.request.POST = {'remove_settings': '1'}
|
||||
response = view.configure(session=self.session)
|
||||
# nb. should get redirect back to configure page
|
||||
self.assertEqual(response.status_code, 302)
|
||||
# should now have 5 settings
|
||||
count = self.session.query(model.Setting).count()
|
||||
self.assertEqual(count, 5)
|
||||
get_setting = functools.partial(self.app.get_setting, self.session)
|
||||
self.assertEqual(get_setting('wutta.app_title'), 'Wutta')
|
||||
self.assertEqual(get_setting('wutta.foo'), 'bar')
|
||||
self.assertEqual(get_setting('wutta.flag'), 'true')
|
||||
self.assertEqual(get_setting('wutta.number'), '42')
|
||||
self.assertEqual(get_setting('wutta.value1'), '')
|
||||
self.assertEqual(get_setting('wutta.value2'), None)
|
||||
|
||||
# should now have 0 settings
|
||||
count = self.session.query(model.Setting).count()
|
||||
self.assertEqual(count, 0)
|
||||
# post request to remove settings
|
||||
self.request.method = 'POST'
|
||||
self.request.POST = {'remove_settings': '1'}
|
||||
response = view.configure(session=self.session)
|
||||
# nb. should get redirect back to configure page
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
# should now have 0 settings
|
||||
count = self.session.query(model.Setting).count()
|
||||
self.assertEqual(count, 0)
|
||||
|
||||
def test_configure_gather_settings(self):
|
||||
view = self.make_view()
|
||||
|
|
Loading…
Reference in a new issue