feat: inherit most logic from wuttaweb, for GridAction

This commit is contained in:
Lance Edgar 2024-08-16 11:56:12 -05:00
parent 09612b1921
commit 1b78bd617c
9 changed files with 65 additions and 61 deletions

View file

@ -137,3 +137,20 @@ class TestGrid(WebTestCase):
# calling again returns same data
data2 = grid.get_vue_data()
self.assertIs(data2, data)
class TestGridAction(WebTestCase):
def test_constructor(self):
# null by default
action = mod.GridAction(self.request, 'view')
self.assertIsNone(action.target)
self.assertIsNone(action.click_handler)
# but can set them
action = mod.GridAction(self.request, 'view',
target='_blank',
click_handler='doSomething(props.row)')
self.assertEqual(action.target, '_blank')
self.assertEqual(action.click_handler, 'doSomething(props.row)')

View file

@ -3,6 +3,7 @@
from unittest.mock import patch
from tailbone.views import master as mod
from wuttaweb.grids import GridAction
from tests.util import WebTestCase
@ -24,3 +25,11 @@ class TestMasterView(WebTestCase):
# sanity / coverage check
kw = view.make_form_kwargs(model_instance=setting)
self.assertIsNotNone(kw['action_url'])
def test_make_action(self):
model = self.app.model
with patch.multiple(mod.MasterView, create=True,
model_class=model.Setting):
view = self.make_view()
action = view.make_action('view')
self.assertIsInstance(action, GridAction)