fix: improve support for random objects with grid, master view
thus far we expected either dict or "native" ORM object which can essentially behave like a dict when needed. but a "non-native" object may not behave like a dict and this hopefully fixes the logic to allow for those anyway..
This commit is contained in:
parent
ba9021c990
commit
dcdc0e7dab
4 changed files with 70 additions and 3 deletions
|
@ -1373,6 +1373,25 @@ class TestGrid(WebTestCase):
|
|||
filters = grid.get_vue_filters()
|
||||
self.assertEqual(len(filters), 2)
|
||||
|
||||
def test_object_to_dict(self):
|
||||
grid = self.make_grid()
|
||||
setting = {'name': 'foo', 'value': 'bar'}
|
||||
|
||||
# new dict but with same values
|
||||
dct = grid.object_to_dict(setting)
|
||||
self.assertIsInstance(dct, dict)
|
||||
self.assertIsNot(dct, setting)
|
||||
self.assertEqual(dct, setting)
|
||||
|
||||
# random object, not iterable
|
||||
class MockSetting:
|
||||
def __init__(self, **kw):
|
||||
self.__dict__.update(kw)
|
||||
mock = MockSetting(**setting)
|
||||
dct = grid.object_to_dict(mock)
|
||||
self.assertIsInstance(dct, dict)
|
||||
self.assertEqual(dct, setting)
|
||||
|
||||
def test_get_vue_context(self):
|
||||
|
||||
# empty if no columns defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue