def testGridbasic_nofields_start(self): """Get a query from a GridModel without fields """ qry = Author.objects.all() import datetime expct_data = [ { "id": 2, 'name': u"tata", 'title': u"MR", 'title_display': "Mr.", 'birth_date': datetime.date(2001, 2, 3) }, { "id": 3, 'name': u"tutu", 'title': u"MRS", 'title_display': "Mrs.", 'birth_date': datetime.date(2002, 3, 4) }, ] ag = AuthorGrid_nofields() raw_result, length = ag.get_rows(qry, start=1) self.assertEqual(expct_data, raw_result) self.assertEqual(length, 3)
def testGridbasic_nofields_limit(self): """Get a query from a GridModel without fields """ qry = Author.objects.all() import datetime expct_data = [ {"id": 2, 'name': u"tata", 'title': u"MR", 'title_display': "Mr.", 'birth_date': datetime.date(2001, 2, 3)}, ] ag = AuthorGrid_nofields() raw_result, length = ag.get_rows(qry, start=1, limit=1) self.assertEqual(expct_data, raw_result) self.assertEqual(length, 3)
def testGridbasic_nofields_noqueryset(self): """Get a query from a GridModel without fields try without queryset """ qry = Author.objects.all() import datetime expct_data = [ {"id": 1, 'name': u"toto", 'title': u"MR", 'title_display': "Mr.", 'birth_date': datetime.date(2000, 1, 2)}, {"id": 2, 'name': u"tata", 'title': u"MR", 'title_display': "Mr.", 'birth_date': datetime.date(2001, 2, 3)}, {"id": 3, 'name': u"tutu", 'title': u"MRS", 'title_display': "Mrs.", 'birth_date': datetime.date(2002, 3, 4)}, ] ag = AuthorGrid_nofields() raw_result, length = ag.get_rows(list(qry),) self.assertEqual(expct_data, raw_result) self.assertEqual(length, 3)