Skip to content

Commit ce662ad

Browse files
committed
Added skipped test to document limitation in sortable column validation
1 parent 90ff085 commit ce662ad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

iommi/table__tests.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
from tests.models import (
9090
AutomaticUrl,
9191
AutomaticUrl2,
92+
Bar,
9293
BooleanFromModelTestModel,
9394
ChoicesModel,
9495
CSVExportTestModel,
@@ -4733,3 +4734,25 @@ def preprocess_rows(rows, **_):
47334734
t = t.bind(request=req('get', **{'order': 'synthetic'}))
47344735

47354736
assert not t.columns.synthetic.sortable
4737+
4738+
4739+
@pytest.mark.skip('Validation is only done on the first level, not on nested levels for now')
4740+
@pytest.mark.django_db
4741+
def test_disallow_sorting_on_non_sortable_columns_that_have_valid_attr__nested():
4742+
Bar.objects.create(pk=1, foo=Foo.objects.create(foo='1'))
4743+
4744+
def preprocess_rows(rows, **_):
4745+
for row in rows:
4746+
row.foo.synthetic = 1
4747+
return rows
4748+
4749+
t = Table(
4750+
auto__model=Bar,
4751+
preprocess_rows=preprocess_rows,
4752+
columns__synthetic=Column(attr='foo__synthetic'),
4753+
)
4754+
4755+
# This should not crash
4756+
t = t.bind(request=req('get', **{'order': 'foo__synthetic'}))
4757+
4758+
assert not t.columns.synthetic.sortable

0 commit comments

Comments
 (0)