zcbot/tests/test_web_common.py

25 lines
763 B
Python

import unittest
from web.common import parse_ordering
class TaskOrderingTests(unittest.TestCase):
def test_default_ordering_uses_latest_update_first(self):
ordering = parse_ordering(None)
self.assertEqual([str(clause) for clause in ordering], ["tasks.updated_at DESC"])
def test_invalid_ordering_falls_back_to_latest_update_first(self):
ordering = parse_ordering("not_a_field")
self.assertEqual([str(clause) for clause in ordering], ["tasks.updated_at DESC"])
def test_explicit_created_at_ordering_remains_supported(self):
ordering = parse_ordering("-created_at")
self.assertEqual([str(clause) for clause in ordering], ["tasks.created_at DESC"])
if __name__ == "__main__":
unittest.main()