test_tables.py 783 B

123456789101112131415161718192021222324
  1. from django.test import RequestFactory, TestCase, tag
  2. from extras.models import EventRule
  3. from extras.tables import EventRuleTable
  4. @tag('regression')
  5. class EventRuleTableTest(TestCase):
  6. def test_every_orderable_field_does_not_throw_exception(self):
  7. rule = EventRule.objects.all()
  8. disallowed = {
  9. 'actions',
  10. }
  11. orderable_columns = [
  12. column.name for column in EventRuleTable(rule).columns if column.orderable and column.name not in disallowed
  13. ]
  14. fake_request = RequestFactory().get('/')
  15. for col in orderable_columns:
  16. for direction in ('-', ''):
  17. table = EventRuleTable(rule)
  18. table.order_by = f'{direction}{col}'
  19. table.as_html(fake_request)