Ejemplo n.º 1
0
 def test_json(self):
     from ..main.models import Author
     from adrest.utils.serializer import JSONSerializer
     authors = Author.objects.all()
     worker = JSONSerializer()
     test = worker.serialize(authors)
     self.assertTrue("main.author" in test)
Ejemplo n.º 2
0
def adrest_jsonify(content, **options):
    """ Serialize any object to JSON .

    :return str: Rendered string.

    """
    from adrest.utils.serializer import JSONSerializer
    worker = JSONSerializer(**options)
    return worker.serialize(content)
Ejemplo n.º 3
0
def adrest_jsonify(content, **options):
    """ Serialize any object to JSON .

    :return str: Rendered string.

    """
    from adrest.utils.serializer import JSONSerializer
    worker = JSONSerializer(**options)
    return worker.serialize(content)
Ejemplo n.º 4
0
    def test_json(self):
        from ...main.models import Author
        from adrest.utils.serializer import JSONSerializer

        authors = Author.objects.all()
        worker = JSONSerializer(options=dict(separators=(',', ':')))
        test = worker.serialize(authors)
        self.assertTrue("main.author" in test)
        self.assertTrue('":{"' in test)
Ejemplo n.º 5
0
    def test_json(self):
        from ...main.models import Author
        from adrest.utils.serializer import JSONSerializer

        authors = Author.objects.all()
        worker = JSONSerializer(options=dict(
            separators=(',', ':')
        ))
        test = worker.serialize(authors)
        self.assertTrue("main.author" in test)
        self.assertTrue('"fields":{"active":true,"name"' in test)
Ejemplo n.º 6
0
def adrest_jsonify(content, **options):
    " Serialize to JSON any object. "

    from adrest.utils.serializer import JSONSerializer
    worker = JSONSerializer(**options)
    return worker.serialize(content)