# Path: fuocore/models.py
# class Model(metaclass=ModelMeta):
#     """base class for data models
# 
#     Usage::
# 
#         class User(Model):
#             class Meta:
#                 fields = ['name', 'title']
# 
#         user = UserModel(name='xxx')
#         assert user.name == 'xxx'
#         user2 = UserModel(user)
#         assert user2.name == 'xxx'
#     """
# 
#     def __init__(self, obj=None, **kwargs):
#         for field in self._meta.fields:
#             setattr(self, field, getattr(obj, field, None))
# 
#         for k, v in kwargs.items():
#             if k in self._meta.fields:
#                 setattr(self, k, v)


from fuocore.models import Model as Struct
        def __init__(self, name, **kwargs):
            super(User, self).__init__(name=name, **kwargs)

    user = User(name='hello', age=10)
    assert user.name == 'hello'
    assert user.age == 10


def test_mix():
    class User(Struct):
        class Meta:
            fields = ['name', 'age', 'birthday']

    user = User(name='lucy', age=20, birthday='2017')

    class VIP(User):
        class Meta:
            fields = ['level']

    vip = VIP(user, level=1)
    vip2 = VIP(name='ysw', level=1)

    assert vip.name == 'lucy'
    assert vip.level == 1
    assert vip2.name == 'ysw'
    assert vip2.level == 1
    assert vip2.age is None


def test_mixins():

# Path: fuocore/models.py
# class Model(metaclass=ModelMeta):
#     """base class for data models
# 
#     Usage::
# 
#         class User(Model):
#             class Meta:
#                 fields = ['name', 'title']
# 
#         user = UserModel(name='xxx')
#         assert user.name == 'xxx'
#         user2 = UserModel(user)
#         assert user2.name == 'xxx'
#     """
# 
#     def __init__(self, obj=None, **kwargs):
#         for field in self._meta.fields:
#             setattr(self, field, getattr(obj, field, None))
# 
#         for k, v in kwargs.items():
#             if k in self._meta.fields:
#                 setattr(self, k, v)


# Path: tests/test_model_base.py
from fuocore.models import Model as Struct

        def __init__(self, name, **kwargs):
            super(User, self).__init__(name=name, **kwargs)

    user = User(name='hello', age=10)
    assert user.name == 'hello'
    assert user.age == 10


def test_mix():
    class User(Struct):
        class Meta:
            fields = ['name', 'age', 'birthday']

    user = User(name='lucy', age=20, birthday='2017')

    class VIP(User):
        class Meta:
            fields = ['level']

    vip = VIP(user, level=1)
    vip2 = VIP(name='ysw', level=1)

    assert vip.name == 'lucy'
    assert vip.level == 1
    assert vip2.name == 'ysw'
    assert vip2.level == 1
    assert vip2.age is None


def test_mixins():

    class User(Struct):