# Path: invenio_files_rest/serializer.py
# class BaseSchema(InvenioRestBaseSchema):
# class BucketSchema(BaseSchema):
# class ObjectVersionSchema(BaseSchema):
# class MultipartObjectSchema(BaseSchema):
# class PartSchema(BaseSchema):
#     def dump_links(self, o):
#     def dump_links(self, o):
#     def dump_tags(self, o):
#     def dump_links(self, o):
#     def wrap(self, data, many):
#     def dump_links(self, o):
#     def wrap(self, data, many):
# def schema_from_context(context, serializer_mapping):
# def _format_args():
# def wait_for_taskresult(task_result, content, interval, max_rounds):
#     def _whitespace_waiting():
# def json_serializer(data=None, code=200, headers=None, context=None,
#                     etag=None, task_result=None,
#                     serializer_mapping=serializer_mapping, view_name=None):


from marshmallow import fields
from invenio_files_rest.serializer import BaseSchema, json_serializer, \
    serializer_mapping
#
# This file is part of Invenio.
# Copyright (C) 2019 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Test serializer."""




def test_serialize_pretty(app):
    """Test pretty JSON."""
    class TestSchema(BaseSchema):
        title = fields.Str(attribute='title')

    data = {'title': 'test'}
    context = {'bucket': '11111111-1111-1111-1111-111111111111',
               'class': 'TestSchema', 'many': False}

    serializer_mapping['TestSchema'] = TestSchema

    # TODO This test should be checked if it shouldn't have
    #  BaseSchema instead of Schema
    with app.test_request_context():
        assert json_serializer(data=data, context=context).data == \
            b'{"title":"test"}'

    with app.test_request_context('/?prettyprint=1'):

# Path: invenio_files_rest/serializer.py
# class BaseSchema(InvenioRestBaseSchema):
# class BucketSchema(BaseSchema):
# class ObjectVersionSchema(BaseSchema):
# class MultipartObjectSchema(BaseSchema):
# class PartSchema(BaseSchema):
#     def dump_links(self, o):
#     def dump_links(self, o):
#     def dump_tags(self, o):
#     def dump_links(self, o):
#     def wrap(self, data, many):
#     def dump_links(self, o):
#     def wrap(self, data, many):
# def schema_from_context(context, serializer_mapping):
# def _format_args():
# def wait_for_taskresult(task_result, content, interval, max_rounds):
#     def _whitespace_waiting():
# def json_serializer(data=None, code=200, headers=None, context=None,
#                     etag=None, task_result=None,
#                     serializer_mapping=serializer_mapping, view_name=None):


# Path: tests/test_serializer.py
from marshmallow import fields
from invenio_files_rest.serializer import BaseSchema, json_serializer, \
    serializer_mapping

#
# This file is part of Invenio.
# Copyright (C) 2019 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Test serializer."""




def test_serialize_pretty(app):
    """Test pretty JSON."""
    class TestSchema(BaseSchema):
        title = fields.Str(attribute='title')

    data = {'title': 'test'}
    context = {'bucket': '11111111-1111-1111-1111-111111111111',
               'class': 'TestSchema', 'many': False}

    serializer_mapping['TestSchema'] = TestSchema

    # TODO This test should be checked if it shouldn't have
    #  BaseSchema instead of Schema
    with app.test_request_context():
        assert json_serializer(data=data, context=context).data == \
            b'{"title":"test"}'

    with app.test_request_context('/?prettyprint=1'):

        assert json_serializer(data=data, context=context).data == \