Пример #1
0
    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')
Пример #2
0
    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')
Пример #3
0
 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())
Пример #4
0
    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())