mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-29 05:42:09 +02:00
Mark provider, member, and action_object columns as non-orderable since they use complex accessors that cannot be sorted. Add regression tests to verify all orderable columns render without exceptions. Fixes table rendering errors when attempting to sort columns with multi-level field accessors that don't support database ordering.
25 lines
783 B
Python
25 lines
783 B
Python
from django.test import RequestFactory, TestCase, tag
|
|
|
|
from extras.models import EventRule
|
|
from extras.tables import EventRuleTable
|
|
|
|
|
|
@tag('regression')
|
|
class EventRuleTableTest(TestCase):
|
|
def test_every_orderable_field_does_not_throw_exception(self):
|
|
rule = EventRule.objects.all()
|
|
disallowed = {
|
|
'actions',
|
|
}
|
|
|
|
orderable_columns = [
|
|
column.name for column in EventRuleTable(rule).columns if column.orderable and column.name not in disallowed
|
|
]
|
|
fake_request = RequestFactory().get('/')
|
|
|
|
for col in orderable_columns:
|
|
for direction in ('-', ''):
|
|
table = EventRuleTable(rule)
|
|
table.order_by = f'{direction}{col}'
|
|
table.as_html(fake_request)
|