# Path: apps/library/models/book.py
# class Book(models.Model):
#     name = models.CharField(_('name'), max_length=1024)
#     authors = models.ManyToManyField('library.Author', verbose_name=_('authors'),
#                                   blank=False, related_name='books')
#     publishers = models.ManyToManyField('library.Publisher', verbose_name=_('publishers'),
#                                         blank=True, related_name='books')
#     description = models.TextField(_('description'), default='', blank=True)
#     tags = models.ManyToManyField('library.Tag', verbose_name=_('tags'),
#                                   blank=True, related_name='books')
#     specializations = models.ManyToManyField('employees.specialization',
#                                              blank=True, related_name='books',
#                                              verbose_name=_('specializations'))
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('book')
#         verbose_name_plural = _('books')
# 
# Path: apps/library/models/offer.py
# class Offer(models.Model):
#     book = models.OneToOneField('library.Book', blank=True, default=None,
#                                 verbose_name=_('book'), related_name='offer',
#                                 null=True)
#     employee = models.ForeignKey('employees.Employee',
#                                  verbose_name=_('employee'),
#                                  related_name='book_offers')
#     name = models.CharField(_('name'), max_length=512, default='', blank=True)
#     url = models.CharField(_('url'), max_length=512, default='', blank=True)
#     price = models.IntegerField(_('price'), default=0)
#     count = models.PositiveIntegerField(_('count'), default=1)
#     description = models.TextField(_('description'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name or self.url
# 
#     class Meta:
#         verbose_name = _('offer')
#         verbose_name_plural = _('offers')
# 
# Path: apps/library/models/holder.py
# class Holder(models.Model):
#     employee = models.ForeignKey('employees.Employee',
#                                  verbose_name=_('employee'),
#                                  related_name='holder_history')
#     book = models.ForeignKey('library.Book', related_name='holder_history',
#                              verbose_name=_('book'))
#     notes = models.TextField(_('notes'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
#     refunded_at = models.DateTimeField(_('refunded at'), null=True, blank=True)
# 
#     class Meta:
#         verbose_name = _('holder')
#         verbose_name_plural = _('holders')
# 
# Path: apps/library/models/tag.py
# class Tag(models.Model):
# 
#     name = models.CharField(_('name'), max_length=256, unique=True)
# 
#     class Meta:
#         verbose_name = _('tag')
#         verbose_name_plural = _('tags')
# 
# Path: apps/library/models/author.py
# class Author(models.Model):
#     name = models.CharField(_('name'), max_length=1024)
#     about = models.TextField(_('about'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('author')
#         verbose_name_plural = _('authors')
# 
# Path: apps/library/models/publisher.py
# class Publisher(models.Model):
#     title = models.CharField(_('name'), max_length=1024)
#     description = models.TextField(_('description'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('publisher')
#         verbose_name_plural = _('publishers')
# 
# Path: apps/employees/models/employee.py
# class Employee(ContactMixin, models.Model):
# 
#     user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='employee')
#     first_name = models.CharField(_('first name'), max_length=128)
#     last_name = models.CharField(_('last name'), max_length=128)
#     middle_name = models.CharField(
#         _('middle name'), default='', max_length=128, blank=True
#     )
#     notes = models.TextField(_('notes'), default='', blank=True)
#     birthday = models.DateField(
#         _('birthday'), default=None, null=True, blank=True
#     )
#     specializations = models.ManyToManyField(
#         'employees.Specialization', verbose_name=_('specializations'),
#         related_name='employees', blank=True
#     )
#     position = models.ForeignKey(
#         'employees.Position', related_name='employees',
#         verbose_name=_('position'),
#     )
#     work_started = models.DateField(_('work started'), default=current_date)
# 
#     def __str__(self):
#         return '{first_name} {last_name}'.format(
#             first_name=self.first_name, last_name=self.last_name
#         )
# 
#     class Meta:
#         verbose_name = _('employee')
#         verbose_name_plural = _('employees')


from django.test import TestCase
from apps.library.models import Book, Holder, Offer, Tag, Author, Publisher
from apps.employees.models import Employee
from model_mommy import mommy




class BookModelTest(TestCase):

    def setUp(self):
        self.book = mommy.make(Book)

    def test_string_representation(self):
        self.assertEqual(str(self.book), self.book.name)

    def test_verbose_name_plural(self):
        self.assertEqual(str(Book._meta.verbose_name_plural), 'books')

    def test_kind_book_create_instance(self):
        self.assertIsInstance(self.book, Book)


class HolderModelTest(TestCase):

    def setUp(self):
        self.holder = mommy.make(Holder)

    def test_verbose_name_plural(self):
        self.assertEqual(str(Holder._meta.verbose_name_plural), 'holders')

    def test_kind_holder_create_instance(self):

# Path: apps/library/models/book.py
# class Book(models.Model):
#     name = models.CharField(_('name'), max_length=1024)
#     authors = models.ManyToManyField('library.Author', verbose_name=_('authors'),
#                                   blank=False, related_name='books')
#     publishers = models.ManyToManyField('library.Publisher', verbose_name=_('publishers'),
#                                         blank=True, related_name='books')
#     description = models.TextField(_('description'), default='', blank=True)
#     tags = models.ManyToManyField('library.Tag', verbose_name=_('tags'),
#                                   blank=True, related_name='books')
#     specializations = models.ManyToManyField('employees.specialization',
#                                              blank=True, related_name='books',
#                                              verbose_name=_('specializations'))
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('book')
#         verbose_name_plural = _('books')
# 
# Path: apps/library/models/offer.py
# class Offer(models.Model):
#     book = models.OneToOneField('library.Book', blank=True, default=None,
#                                 verbose_name=_('book'), related_name='offer',
#                                 null=True)
#     employee = models.ForeignKey('employees.Employee',
#                                  verbose_name=_('employee'),
#                                  related_name='book_offers')
#     name = models.CharField(_('name'), max_length=512, default='', blank=True)
#     url = models.CharField(_('url'), max_length=512, default='', blank=True)
#     price = models.IntegerField(_('price'), default=0)
#     count = models.PositiveIntegerField(_('count'), default=1)
#     description = models.TextField(_('description'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name or self.url
# 
#     class Meta:
#         verbose_name = _('offer')
#         verbose_name_plural = _('offers')
# 
# Path: apps/library/models/holder.py
# class Holder(models.Model):
#     employee = models.ForeignKey('employees.Employee',
#                                  verbose_name=_('employee'),
#                                  related_name='holder_history')
#     book = models.ForeignKey('library.Book', related_name='holder_history',
#                              verbose_name=_('book'))
#     notes = models.TextField(_('notes'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
#     refunded_at = models.DateTimeField(_('refunded at'), null=True, blank=True)
# 
#     class Meta:
#         verbose_name = _('holder')
#         verbose_name_plural = _('holders')
# 
# Path: apps/library/models/tag.py
# class Tag(models.Model):
# 
#     name = models.CharField(_('name'), max_length=256, unique=True)
# 
#     class Meta:
#         verbose_name = _('tag')
#         verbose_name_plural = _('tags')
# 
# Path: apps/library/models/author.py
# class Author(models.Model):
#     name = models.CharField(_('name'), max_length=1024)
#     about = models.TextField(_('about'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.name
# 
#     class Meta:
#         verbose_name = _('author')
#         verbose_name_plural = _('authors')
# 
# Path: apps/library/models/publisher.py
# class Publisher(models.Model):
#     title = models.CharField(_('name'), max_length=1024)
#     description = models.TextField(_('description'), default='', blank=True)
#     created_at = models.DateTimeField(_('created at'), auto_now_add=True)
# 
#     def __str__(self):
#         return self.title
# 
#     class Meta:
#         verbose_name = _('publisher')
#         verbose_name_plural = _('publishers')
# 
# Path: apps/employees/models/employee.py
# class Employee(ContactMixin, models.Model):
# 
#     user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='employee')
#     first_name = models.CharField(_('first name'), max_length=128)
#     last_name = models.CharField(_('last name'), max_length=128)
#     middle_name = models.CharField(
#         _('middle name'), default='', max_length=128, blank=True
#     )
#     notes = models.TextField(_('notes'), default='', blank=True)
#     birthday = models.DateField(
#         _('birthday'), default=None, null=True, blank=True
#     )
#     specializations = models.ManyToManyField(
#         'employees.Specialization', verbose_name=_('specializations'),
#         related_name='employees', blank=True
#     )
#     position = models.ForeignKey(
#         'employees.Position', related_name='employees',
#         verbose_name=_('position'),
#     )
#     work_started = models.DateField(_('work started'), default=current_date)
# 
#     def __str__(self):
#         return '{first_name} {last_name}'.format(
#             first_name=self.first_name, last_name=self.last_name
#         )
# 
#     class Meta:
#         verbose_name = _('employee')
#         verbose_name_plural = _('employees')


# Path: apps/library/tests/test_models.py
from django.test import TestCase
from apps.library.models import Book, Holder, Offer, Tag, Author, Publisher
from apps.employees.models import Employee
from model_mommy import mommy





class BookModelTest(TestCase):

    def setUp(self):
        self.book = mommy.make(Book)

    def test_string_representation(self):
        self.assertEqual(str(self.book), self.book.name)

    def test_verbose_name_plural(self):
        self.assertEqual(str(Book._meta.verbose_name_plural), 'books')

    def test_kind_book_create_instance(self):
        self.assertIsInstance(self.book, Book)


class HolderModelTest(TestCase):

    def setUp(self):
        self.holder = mommy.make(Holder)

    def test_verbose_name_plural(self):
        self.assertEqual(str(Holder._meta.verbose_name_plural), 'holders')

    def test_kind_holder_create_instance(self):

        self.assertIsInstance(self.holder, Holder)