def getReports(self, req): """ Get a list of available reports """ reports = list(Report.select(self.env)) return [{ "id": r.id, "title": r.title, "description": r.description } for r in reports]
def test_select(self): reports = list(Report.select(self.env)) self.assertEqual(1, reports[0].id) self.assertEqual('Active Tickets', reports[0].title) self.assertEqual( " * List all active tickets by priority.\n" " * Color each row based on priority.\n", reports[0].description) self.assertIn("SELECT p.value AS __color__", reports[0].query) self.assertEqual(8, len(reports)) self.assertEqual(1, reports[0].id) self.assertEqual(8, reports[-1].id)
def test_select_order_by_title(self): reports = list(Report.select(self.env, sort='title')) self.assertEqual(8, len(reports)) self.assertEqual(4, reports[0].id) self.assertEqual(7, reports[-1].id)
def test_select_sort_desc(self): reports = list(Report.select(self.env, asc=False)) self.assertEqual(8, len(reports)) self.assertEqual(8, reports[0].id) self.assertEqual(1, reports[-1].id)