3
0
Fork 0

fix: add make_users_grid() method for RoleView

per newer convention
This commit is contained in:
Lance Edgar 2025-01-24 19:00:46 -06:00
parent 91c87e4d85
commit 194d798c0c
2 changed files with 57 additions and 4 deletions

View file

@ -7,6 +7,7 @@ from sqlalchemy import orm
import colander
from wuttaweb.views import roles as mod
from wuttaweb.grids import Grid
from wuttaweb.forms.schema import RoleRef
from wuttaweb.testing import WebTestCase
@ -93,6 +94,27 @@ class TestRoleView(WebTestCase):
view.configure_form(form)
self.assertIsNotNone(form.validators['name'])
def test_make_users_grid(self):
model = self.app.model
view = self.make_view()
role = model.Role(name="Manager")
# basic
grid = view.make_users_grid(role)
self.assertIsInstance(grid, Grid)
self.assertFalse(grid.linked_columns)
self.assertFalse(grid.actions)
# view + edit actions
with patch.object(self.request, 'is_root', new=True):
grid = view.make_users_grid(role)
self.assertIsInstance(grid, Grid)
self.assertIn('person', grid.linked_columns)
self.assertIn('username', grid.linked_columns)
self.assertEqual(len(grid.actions), 2)
self.assertEqual(grid.actions[0].key, 'view')
self.assertEqual(grid.actions[1].key, 'edit')
def test_unique_name(self):
model = self.app.model
view = self.make_view()