# Path: yithlibraryserver/compat.py
# PY3 = sys.version_info[0] == 3
#     def encode_header(obj):  # pragma: no cover
#     def encode_header(obj):  # pragma: no cover
# 
# Path: yithlibraryserver/user/models.py
# class User(dict):
# 
#     def __unicode__(self):
#         result = self.get('screen_name', '')
#         if result:
#             return result
# 
#         result = ' '.join([self.get('first_name', ''),
#                            self.get('last_name', '')])
#         result = result.strip()
#         if result:
#             return result
# 
#         result = self.get('email', '')
#         if result:
#             return result
# 
#         return text_type(self['_id'])
# 
#     # py3 compatibility
#     def __str__(self):
#         return self.__unicode__()


import unittest
from yithlibraryserver.compat import text_type
from yithlibraryserver.user.models import User
# Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com>
#
# This file is part of Yith Library Server.
#
# Yith Library Server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.




class UserTests(unittest.TestCase):

    def test_unicode(self):
        data = {'_id': '1234'}
        self.assertEqual(text_type(User(data)), '1234')

        data['email'] = 'john@example.com'
        self.assertEqual(text_type(User(data)), 'john@example.com')

        data['last_name'] = 'Doe'

# Path: yithlibraryserver/compat.py
# PY3 = sys.version_info[0] == 3
#     def encode_header(obj):  # pragma: no cover
#     def encode_header(obj):  # pragma: no cover
# 
# Path: yithlibraryserver/user/models.py
# class User(dict):
# 
#     def __unicode__(self):
#         result = self.get('screen_name', '')
#         if result:
#             return result
# 
#         result = ' '.join([self.get('first_name', ''),
#                            self.get('last_name', '')])
#         result = result.strip()
#         if result:
#             return result
# 
#         result = self.get('email', '')
#         if result:
#             return result
# 
#         return text_type(self['_id'])
# 
#     # py3 compatibility
#     def __str__(self):
#         return self.__unicode__()


# Path: yithlibraryserver/user/tests/test_models.py
import unittest
from yithlibraryserver.compat import text_type
from yithlibraryserver.user.models import User

# Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com>
#
# This file is part of Yith Library Server.
#
# Yith Library Server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Yith Library Server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Yith Library Server.  If not, see <http://www.gnu.org/licenses/>.




class UserTests(unittest.TestCase):

    def test_unicode(self):
        data = {'_id': '1234'}
        self.assertEqual(text_type(User(data)), '1234')

        data['email'] = 'john@example.com'
        self.assertEqual(text_type(User(data)), 'john@example.com')

        data['last_name'] = 'Doe'

        self.assertEqual(text_type(User(data)), 'Doe')