示例#1
0
文件: tests.py 项目: intaxi/adrest
 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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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)