# Path: tests/fixtures/thief.py
# class Thief(object):
#     """Thief fake class"""
# 
#     def __init__(self, first_name, last_name):
#         """
#         Args:
#             first_name (str): thief first name
#             last_name (str): thief last name
#         """
#         self.first_name = first_name
#         self.last_name = last_name
# 
# Path: tests/fixtures/book.py
# class Book(object):
#     def __init__(self, title, authors):
#         self.title = title
#         self.authors = authors


import pytest
from lupin import Constant, fields as f, Mapper, Schema
from lupin.processors import strip, lower
from lupin.errors import InvalidDocument, InvalidType, MissingKey, ValidationError
from tests.fixtures import Thief, Book
            "first_name": None,
            "last_name": "Lupin"
        }

    def test_returns_no_attr_if_allow_partial_and_missing_key(self, thief_schema, thief_data, mapper):
        del thief_data["firstName"]
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "last_name": "Lupin"
        }

    def test_do_not_load_read_only_attribute(self, thief_schema, thief_data, mapper):
        thief_schema.add_field("lastName", f.String(read_only=True))
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "first_name": "Arsène"
        }

    def test_use_processors(self, thief_schema, thief_data, mapper):
        thief_schema.add_field("lastName",
                               f.String(pre_load=[strip], post_load=[lower], binding="last_name"))
        thief_data["lastName"] = "  LuPin  "
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "last_name": "lupin",
            "first_name": "Arsène"
        }

    def test_load_list_pre_load(self, book_schema, mapper):
        """check pre_load is called on elements of the list, and the pre_load of the list also"""

# Path: tests/fixtures/thief.py
# class Thief(object):
#     """Thief fake class"""
# 
#     def __init__(self, first_name, last_name):
#         """
#         Args:
#             first_name (str): thief first name
#             last_name (str): thief last name
#         """
#         self.first_name = first_name
#         self.last_name = last_name
# 
# Path: tests/fixtures/book.py
# class Book(object):
#     def __init__(self, title, authors):
#         self.title = title
#         self.authors = authors


# Path: tests/lupin/test_schema.py
import pytest
from lupin import Constant, fields as f, Mapper, Schema
from lupin.processors import strip, lower
from lupin.errors import InvalidDocument, InvalidType, MissingKey, ValidationError
from tests.fixtures import Thief, Book

            "first_name": None,
            "last_name": "Lupin"
        }

    def test_returns_no_attr_if_allow_partial_and_missing_key(self, thief_schema, thief_data, mapper):
        del thief_data["firstName"]
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "last_name": "Lupin"
        }

    def test_do_not_load_read_only_attribute(self, thief_schema, thief_data, mapper):
        thief_schema.add_field("lastName", f.String(read_only=True))
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "first_name": "Arsène"
        }

    def test_use_processors(self, thief_schema, thief_data, mapper):
        thief_schema.add_field("lastName",
                               f.String(pre_load=[strip], post_load=[lower], binding="last_name"))
        thief_data["lastName"] = "  LuPin  "
        attrs = thief_schema.load_attrs(thief_data, mapper, allow_partial=True)
        assert attrs == {
            "last_name": "lupin",
            "first_name": "Arsène"
        }

    def test_load_list_pre_load(self, book_schema, mapper):
        """check pre_load is called on elements of the list, and the pre_load of the list also"""

        book = book_schema.load(Book,