# 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/jewel.py
# class Jewel(object):
#     def __init__(self, name, carat):
#         self.name = name
#         self.carat = carat
# 
# Path: tests/fixtures/painting.py
# class Painting(object):
#     def __init__(self, name, author):
#         self.name = name
#         self.author = author


import pytest
from lupin import Mapper, Schema
from lupin.errors import MissingMapping, SchemaAlreadyRegistered, InvalidDocument, \
    InvalidPolymorphicType, SchemaNotRegistered
from tests.fixtures import Thief, Painting, Jewel

    def test_works_with_schema_name(self, mapper, thief, thief_data):
        data = mapper.dump(thief, "thief")
        assert data == thief_data


class TestLoad(object):
    @pytest.fixture(autouse=True)
    def mapping(self, mapper, thief_schema):
        mapper.register(Thief, thief_schema)

    def test_returns_a_thief(self, mapper, thief_data, thief_schema):
        thief = mapper.load(thief_data, thief_schema)
        assert isinstance(thief, Thief)

    def test_loads_list(self, mapper, thief_data, thief_schema):
        thieves = mapper.load([thief_data], thief_schema)
        assert isinstance(thieves, list)
        assert isinstance(thieves[0], Thief)

    def test_load_with_schema_name(self, mapper, thief_data):
        thieves = mapper.load([thief_data], "thief")
        assert isinstance(thieves, list)
        assert isinstance(thieves[0], Thief)


class TestLoadPolymorphic(object):
    @pytest.fixture(autouse=True)
    def setup(self, mapper, painting_schema, jewel_schema):
        mapper.register(Jewel, jewel_schema)

# 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/jewel.py
# class Jewel(object):
#     def __init__(self, name, carat):
#         self.name = name
#         self.carat = carat
# 
# Path: tests/fixtures/painting.py
# class Painting(object):
#     def __init__(self, name, author):
#         self.name = name
#         self.author = author


# Path: tests/lupin/test_mapper.py
import pytest
from lupin import Mapper, Schema
from lupin.errors import MissingMapping, SchemaAlreadyRegistered, InvalidDocument, \
    InvalidPolymorphicType, SchemaNotRegistered
from tests.fixtures import Thief, Painting, Jewel


    def test_works_with_schema_name(self, mapper, thief, thief_data):
        data = mapper.dump(thief, "thief")
        assert data == thief_data


class TestLoad(object):
    @pytest.fixture(autouse=True)
    def mapping(self, mapper, thief_schema):
        mapper.register(Thief, thief_schema)

    def test_returns_a_thief(self, mapper, thief_data, thief_schema):
        thief = mapper.load(thief_data, thief_schema)
        assert isinstance(thief, Thief)

    def test_loads_list(self, mapper, thief_data, thief_schema):
        thieves = mapper.load([thief_data], thief_schema)
        assert isinstance(thieves, list)
        assert isinstance(thieves[0], Thief)

    def test_load_with_schema_name(self, mapper, thief_data):
        thieves = mapper.load([thief_data], "thief")
        assert isinstance(thieves, list)
        assert isinstance(thieves[0], Thief)


class TestLoadPolymorphic(object):
    @pytest.fixture(autouse=True)
    def setup(self, mapper, painting_schema, jewel_schema):
        mapper.register(Jewel, jewel_schema)

        mapper.register(Painting, painting_schema)