def test_serialize(self): class F: no_calls = 0 def call(*args, **kw): F.no_calls += 1 d = Table("name", "querySet", []) d.serializeToJSON = call d.serializeToCSV = call d.serializeToXLS = call for fmt in [formats.XLS, formats.JSON, formats.CSV]: d.serialize(None, fmt) self.assertEquals(F.no_calls, 3) self.assertRaises(formats.UnknownFormat, d.serialize, None, 'unknown format')
def test_serialize(self): class F: no_calls = 0 def call(*args, **kw): F.no_calls += 1 d = Table("name", "querySet", []) d.serializeToJSON = call d.serializeToCSV = call d.serializeToXLS = call for fmt in [formats.XLS, formats.JSON, formats.CSV]: d.serialize(None, fmt) self.assertEquals(F.no_calls, 3) self.assertRaises( formats.UnknownFormat, d.serialize, None, 'unknown format')
def test_serializeToJSON(self): class FakeRequest: GET = dict(sort='first_name', start=0, count=2) d = Table("name", User.objects.all(), [('first_name', 'label')]) d.serializeToJSON(FakeRequest())