feat: move single-column grid sorting logic to wuttaweb
This commit is contained in:
parent
c95e42bf82
commit
ec36df4a34
7 changed files with 475 additions and 200 deletions
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from tailbone.views import master as mod
|
||||
from wuttaweb.grids import GridAction
|
||||
|
@ -33,3 +33,34 @@ class TestMasterView(WebTestCase):
|
|||
view = self.make_view()
|
||||
action = view.make_action('view')
|
||||
self.assertIsInstance(action, GridAction)
|
||||
|
||||
def test_index(self):
|
||||
self.pyramid_config.include('tailbone.views.common')
|
||||
self.pyramid_config.include('tailbone.views.auth')
|
||||
model = self.app.model
|
||||
|
||||
# mimic view for /settings
|
||||
with patch.object(mod, 'Session', return_value=self.session):
|
||||
with patch.multiple(mod.MasterView, create=True,
|
||||
model_class=model.Setting,
|
||||
Session=MagicMock(return_value=self.session),
|
||||
get_index_url=MagicMock(return_value='/settings/'),
|
||||
get_help_url=MagicMock(return_value=None)):
|
||||
|
||||
# basic
|
||||
view = self.make_view()
|
||||
response = view.index()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# then again with data, to include view action url
|
||||
data = [{'name': 'foo', 'value': 'bar'}]
|
||||
with patch.object(view, 'get_data', return_value=data):
|
||||
response = view.index()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.content_type, 'text/html')
|
||||
|
||||
# then once more as 'partial' - aka. data only
|
||||
self.request.GET = {'partial': '1'}
|
||||
response = view.index()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue